Added some documentation. Small performance improvement