Optimizer

fixes #8 #9