bugfix and improvements