Trying to explain some ideas. This is the accompanying code.