Refactor coed and add some comments.