add some type annotations to the Optimizer code