several bugfixes and adjustments