Refactor all code and almost finish the game