beautified code

mostly added comments, no real code changes