Fixed insert method to use correct attribute. Added null checking to metadata extraction.