API to register callbacks

Fixes #106