refactoring code. make output of optimized plans deterministic. add new
test cases