Improve query functions of Map and Set.