Version checking refactored

Close #427.