Fix some constness and add comments.