Finalizing optomization and rewrites