several bugfixes and changes