COSMIT remove unused imports and variables

A number of pyflakes errors.