Improve documentation and comments

I improved some of the comments and added some detail.