Bugfixes, now compiles and "make test" is running