Refactor message handlers to use command hash instead of switch statemen...

...ts