Fix stack level too deep errors for metadata