Merge pull request #1 from lemanal/master

Fix reference to self & remove print statement
Some minor cleanups and nice properties

TODO clean up commit into two seperate commits
Add handler for disconnect
recv_loop: Call disconnect handler on socket error.