various pep-8 cleanups; remove unsused imports; remove unused variables

A number of PEP-8 related cleanups. Also removing unused imports and unused variables.