Added page load event listener; Sped up event loop

The funtions that execute "automatically" are now wrapped in an event listener that
waits for the page to load, allowing the html to populate.

The event loop now checks for button presses every 40 ms.