Fixed crashes due to operation being nilled before being able to set it, so we added a check for operation and key