Minor refactoring

Some minor refactoring (mostly renames) that I made while I was getting to grips with the code.