Updated to clear keys before resetting.