Just some code cleanup

Just the first stage of a small code cleanup; trying to avoid introducing new bugs into this project.