fix async issue (missing final callback on applyEachSeries
refactoring regarding template variables setting