Final version with comments.