Fix im3 metadata

See gh-1383.  This is the two original commits from that PR, with merge conflicts resolved and one more commit to address the metadata filtering comment.