Spliting rewrite files into a separate branch
Cleanups and error fixes suggested by flake8 (pep8 + pyflakes)