Fixes, optimizations