Seperated out the optimizer into its own module