Split game code up for better maintainability + a few small bugfixes