Fix array bound infringement bug when battery under charge is zero (no battery allocated)