some bugfix and improvement