Cleaned up tabs, ported to py3, misc cleanups.