Minorr code cleanup and documentation