Allow optimize parameter to be defined

If opts.optimize is passed in, it should be preferred.