Add support for optimizing an index.
Merge branch 'optimize-index'