Some work on the p2p system
Fix several bugs in peer.js and enable it to successfully connect to a peer (tested with bitcoind).