Added a timing system to the main loop