Command manager

A cleaner version of the command processer, it's easier to read and (if run with assertions enabled) will alert when a command takes invalid paramaters (doesn't take message as first argument).

I've also refactored all the test cases which used the old methods so this should fail to merge now :).