Refactored some of the code and removed some code duplication. (#504)
Refactored some of the code and removed some code duplication. (#504)

* Refactored some of the code and removed some code duplication.

* Made small modifications.

* Re-added the task check.

* Re-added the task check.
google/turbinia,google/turbinia,google/turbinia,google/turbinia,google/turbinia