Minor code tidying and commentary.