Tidying. Trying to understand the code, and tidying it up a little as I do so. ...