Small performance improvements.
Fixed some typos in comments.