Change onOptimize to done and add documentation.