Refactored received command

Received commands are handled more humanely. Added logging for all device events (including sending commands).

@pdehaan r?