with minor improvements in modularity and major improvements in game loop