removed several global variables, refactored some methods to reflect changes