Refactored task into std::shared_ptr<fn>

- Removed the task class and replaced it with a typedef
- Cleaned up many APIs that were just not working right
- Fixed a memory leak due to C++11 refactorings