Implemented lots of stuff in server, see diff