Fixes NPEs with contact queries.