Add a lot of comments to make the templates more readable (kinda)

Actually I forgot what most of the code did so the best way to
understand it again was to comment everything. Plus it might allow other
people to understand what happens here :)