Fix error saving metadata