Conversion to new callback model.

Comparision with original shows identical results and no errors under
valgrind.