fixed scoping for global 'l'.
Really fixed scoping for l variable by pulling calls into
scope.
last of the misc errors in violation of pep 8.