More comments to make it clear how it works. And better code.