Fix a few lingering bugs and do some more pythonification