Optimizing Battery Management Systems for Electric Vehicles