Corrected documentation and small code optimizations