Some code cleanup and comments.