FVEoptRun: Main loop moved to function mainLoop