Refactor step 1

Separate stuff into modules, make serversession take in full message.
Extract common stuff into master session