Fix bugs in handshake procedure.

* Fix memory bug in packet-io when handshake fails;
* Make sure received peer id matches expected one;
* Remove ENABLE_DEBUG macro.