Various server fixes

* Make connection more stable
* Rejig state packing to match client