Add debug messages for testing

It is only working on Windows. Obviously that is not good, as it needs
to be cross-platform. :(

Also move debugPrint function to a better place.