Code cleanup and misfit plotting in model 2