Minor cleanup and made compatible with Python3
Fixed minor error causing problems in 2.7