Performance improvement in ResidenceManager.getByLoc

See #84.
I've just squashed commits.