Lots of refactoring and variable name changes.