Changed overuse of variables in some areas. Cleaned up code and comments