Another round of code polishing based on PR comments.