Its currently in collection.h, and since it has to do a lot of ugly crap I think its fine there.
When we can remove the dependencies on all the other things we can refactor it into api/ later