Refactored more code

Changed lots of shit.
There is currently a bug where multiple clients don't work properly.