It was always only using the flags from the first source layer of a given type, not from the layer actually being handled. This was (probably) more or less harmless for the CD_FLAG_NOCOPY test, but could be really bad when checking CD_FLAG_NOFREE, and when copying the flags over to new copied data!