Implemented header parsing, protocol handling

and other cool stuff