Recognizing and avoiding hazards