Add support for perIteration callback (fix #2)