Added error logging and wrapped metadata creation in a transaction