Fixed a number of methods and looks for different environment variables

This version has mostly working functions and uses a slightly different set of class variables.

Methods require further testing, but this fixes bugs in the current project that were making it fail.