Minor Optimizations and Bugfixes