Bugfixes in tasks.py