Intermediate bugfixing commit. Not all tests pass yet!!