added more documentation in task code

This is done with the [JSDoc](http://en.wikipedia.org/wiki/JSDoc) conventions.