More logic cleanup and some documentation / comment improvements.