Fix mutable bug in finalize schema function.