Lots of server/client fixes