Mostly bug fixes

Problems with threading on the gateway fixed
New packets for notification and handling of device registration
AccountServer updated for better support.