a) remove unnecessary debug
b) add error checking for incoming messages