BMS for energy storage system