Minor bug fixes and code comments