Small cleanup of Optimize func