Implement parsing and executing of commands, and re-structure some classes