Reorganized CLI code in more files