Does esp8266 save old sketches?

I don't know if the esp8266 itself keeps the old firmware, but I wonder if the OTA library does. It must store the new firmware, as it is uploaded, in an unused part of the flash memory. It can't simply overwrite the old firmware in case the new firmware download fails part way through or gets corrupted. If I designed the OTA library, I think I would build in some kind of failsafe. If the new firmware, even though it downloaded ok, did not behave correctly in some particular way, not sure what that might be exactly, the library would intervene and switch back to the previous firmware version, having kept it as a backup.