bugfixes and some changes