Rewrite of tasks.js, fixed output bugs