some bugfix and improvements