bugfix and some refactorings