Small bugfixes and improvements