More bugfixes. Now doesn't crash, gets to handshake.