Finish optimization rewrite