Made incremental non-functional improvements, cleaning things up and
renaming functions.