Canonical callbacks

I've rebased canonical callbacks over master branch. Also changed the test cases. All test cases are passing.