Stop leaking globals

Used var hoisting.  Could use one var per line, if desired, instead.