fix imports and other small bugs, pep8/pyflakes.