Bugfixes and improvements.