Implemented @daniel-beck’s suggestion for defense against build number duplication.
Defend against out-of-order builds even if nextBuildNumber is wrong.