Rewrote most of the old code

Also started on the multiplayer part