Minor bugfix and improvements.