Refactor to make key generator clearer and clarify difference in using Proc or lambda in mods