Modified and added some debugging output to Python version.