Some bugfixes / Optimization