Fixed metadata loss bug