Bugfixes and much more extensive testing