added boolean argument to beforeTask() and afterTask() callbacks to allow distinguish between real task execution and clear-method calls