Tidying up code and started work on new command infrastructure.