Fixes a bug replacing keys.