Changed handshake reading logic. Fixes #13