Improve debugging and comments
Improve debug, fix while loop expression