Bugfixes / optimizations