Main loop and graphics loader