Optimizations and Fixes