bugfix and optimization to evaluation of harmonic series