Lots of interface fixes, bugfixes.

Python test suite now passes locally