bugfixes by thomas