cleaned the code a bit. Now has working Two state optimizer with imporved result. Need to put more data