Optimizations and documentation fixes