Renamed variables, generally cleaned up some code.