Reduced code duplication around running tasks and handling their exceptions
I also added javadocs for a few protected functions which previously did not have any.