some bugfixes and improvements