More command parsing, some refactoring.