Command manager

This tidies up the command processor so it's easier to follow :).