Resolve issue where metadata was being discarded too early