Refactor name generation and fix some CLI issues