Add more logging statements. Remove old code. Fix up some comments and pyflakes/pep8