improved code comments throughout