refactored the code to use a private configuration object instead of global configuration variables. the code has been tested pretty extensively and the changes seem to behave correctly