Changed the way keys are generated to avoid leading underscore when prefix is nil.