First bugfixes during testing.
Prevented infinite loop on handleMessageType. Added debug prints.