Metadata upgrade and bug fixes