Speed up version check

Fixes #2269