Optimizations and documenting code