Add init and uninit functions to cmdutils, reduces code duplication