Added a lot of global variables. Corrected for negative temperatures.