Extract #modify_keys! (private method)