changes to main loop - timer etc
fixed merge conflicts