Replaced some occurrences of resignFirstResponder with self.view endEditing: and removed extraneous variables