add a bit of whitespace/cr/lf to make it easier to read
cleanup comments, add a few log statements
remove dead code
remove dead code
add a few comments