Fixed bugs with updating keys