Generalize ObjectID wrapper for the right kinds of queries. Should fix issue with more complex queries