lots of fixes; testsuite passes