several bugfixes & improvements