Fixes some nasty bugs in the game