Improved ObjectQuery handling