Cleaned up code, added comments, disambiguated variable names