more better comments, variable scope cleanup