Refactor string formatting to use format()
Refactor code style from if(): while(): fncall( x ), to if: while: fncall(x)
Improve debug messages