Minor bug fixes and additional comments

Minor bug fixes and additional comments