Refactor key mapping.
Fixed bug in expansion of ambiguous match prefix.