code tweaks and performance optimizations in hasAssociation()/hasField()