Make maximum key length configurable.
Refactor for cleanup.
More refactor.