Add callbacks capability (taken from hildjj/macgap).