Optimization of lithium in secondary battery system