Modularize code down to tasks.

I could probably break this down further.