Finish porting to CLI version