Some little bugfixes and improvements