Several bugfixes.
Avoid matching with self during hash lookup.