Fix version handling so it can cope with a major version >3.