Added comments for future reference, plus some other minor tweaks.