Added logging to fix metadata write