I added comments. Take a look if you understand them.
I will merge them end of today, because I have the next PR ready, that depends on this.