Misc changes for C++11.

- Changed NULL to nullptr throughout all C++ code.
- Switched to using std::function instead of self-rolled Functor class.