Restructure the main iteration loop more logically and elegantly and store the variables on the starting surface.