Improved multiplayer code