Updated code to be compatible with Python 2.7.5, used six and from __future__ imports