Started adding comments to functions, tweaked a couple while I was at it