Critical task calculation bug fix

Hi Eric,
sorry about the fuss in pull request #1. To give my code submission a fresh start, I am sending you a new pull request.
(Paolo: stay on-topic, and refrain from posting more personal insults. This is not kindergarten. Thanks.)