Renamed a bunch of functions and globals for easier reading.