Supporting Callback classes

Added tests, documentation and refactored code a bit. Take a look.