Added convenience function for trapping callbacks and storing them