more bugfixes and testing