a bunch of big fixes in both client and server