Separate CLI out and improve it