Do some refactoring and fix the type annotation errors.
Speed up game loop perhaps.