Switch to replace if else structure

A nice switch structure on all possible commands.
The ProtocolException does not work yet :-\
Also need to move the handling of the commands to separate functions