Wip - improves optimizer code organization and makes the optimizer configurable