Refactor to utilize Swift's powerful enums

TaskResult is now much simpler and safer (also broken up into two enums). We can express the same information without having to do unsafe unboxing of optionals anywhere.

Note: I didn't actually change any of the logic in the code, I just moved unsafe unboxing conditionals to safe pattern matching switch statements.

Depends on #1 (I can rebase this out if you want to except this and not #1)