Added comments and made some minor changes.