new updated decision engine and cleaned up code. Engine seems stable,
but needs further testing.