Bugfixes an performance improvements