Handling Lithium-Ion Batteries in Electric Vehicles: Preventing and Recovering from Hazardous Events