Made some changes to make it work with Python 2.7 instead of 3.3