Clean up code using ghc -Wall.

Mostly adding type signatures but also renaming some variables (to
avoid shadowing) and removing some unused functions and imports.
Update tasks.