Minor fix.
Adding a lot of printouts to instrument the code.
Adding more debug outputs.