Minor bugfixes and improvements.