Clean up the mess in the main, seperate testing and normal run.