More documentation and comments on various aspects of the code