Renamed functions; formatted to make more readable