Refactoring; smarter sig decode function
tidied solve function
resetting upstream
dual compatibility with python2/3, a bit less messy