Add back missing dirs and links files and improve clean-up after failure