bugfix and some enhancements