Improved version detection