Battery management algorithms in "non-ideal" vehicle environments