Smarter version checking

Fixes #145