Refactor key normalization

Symbols are translated to spaces, starting and trailing spaces are
stripped, and any remaining spaces are translated to underscores
(treating groups of spaces as a single underscore).

TL;DR Keep me sane.