Bugfix and improvements.