Better error handling, and python2.7 support