Code documentation and minor tweaks