Added some notes to help understand the source code.