enough simple bugfixes to make test_simple_system test pass
enough minor fixes that the test_complex_system test now run successfully