TODO:
  - Error handling.
  - Header restoration.
  - Write UPGRADE file, dealing with incompatibilities, if any.
