Code formating, comments, etc. Added most of Mark's suggestions