Fix logic for generating major/minor version numbers

As suggested by @jouvin.
Also improve commit message!