Move network code to Messenger object.
Merge branch `rewrite` into `master`.