Refactor several debug routines.

To simplify additions of debug routines we replace a custom function
implementation by a simple call.