The final version with comments for source code.