considerably reoganize Main, much easier to work with now
fix nonlinear plots