Bug fix and code comments