Make the key type generic and rename some methods.
Fix unit tests.