Clean up code and rename a few variables.