Merge pull request #832 from mayeut/overflow-check