Fix various bugs in CLI (fixup)