Adds game loop logic, some helper functions.