Put optimizer stuff into its own class