Fixed bug with final task and dependence

b340ac07c932acc9d99ccc2b291561cc04b8554f by Alexey Bataev.