bugfix and cleanup