reorganized and explained parts of code.

You can look at the commits at my repository, since there are many of them and I explained them there.