added protection flag for keys so they are not removed until protection is removed first