bugfixes and performance