Code clean-up and refactoring in CLI helpers