serveral bugfixes