Added extra comments on my ideas of how the code could be shorter.