Corrections and code comments

Some corrections for clarity and re-writing and comments for documentation.