Refactored command parser to remove duplicate functionality.