Reorganized _find_version(), made it give more information in case of errors, and made it more robust against unexpected input