loads of general api fixes, started intergrating socket.io