added null check for metadata, and stripping ONB_ from ONB IDs