a part of PR269 (parallelization of several functions) by Alexander Mordvintsev
Merge pull request #405 from vpisarev:znah_patch