Added a ValueError to fix a nasty crash, reported and patched by https://github.com/maru-sama
Thanks!