Introduce logging in some of the main functions to make it easier to pin down the location of bugs/errors.
Introduce logging in some of the main functions to make it easier to pin down the location of bugs/errors.