Add callbacks and example

- Cleaned up the code.
- Added C++11 based callbacks
- Added example