Refactor internal has and allow iteration

Based on @ccare's excellent work, I've refacted the internals to a hash. I've also added code to allow the results to be iterated. Thoughts please? (cc @malcyL, @ccare)