This was the most controversial change, I believe.  Rather than hardcoding what's here, we should use the metadata that we've stored.  

This logic works for what's there, though I'm not sure it's the most semantically meaningful possible.