 
 /// Module to store programs to disk.
 public class Storage: Module {
+    private let storageDir: String
     private let crashesDir: String
     private let duplicateCrashesDir: String
     private let interestingDir: String
     private let stateFile: String
-    
+
     private let stateExportInterval: Double?
-    
+
     private unowned let fuzzer: Fuzzer
     private let logger: Logger
-    
+
     public init(for fuzzer: Fuzzer, storageDir: String, stateExportInterval: Double? = nil) {
+        self.storageDir = storageDir
         self.crashesDir = storageDir + "/crashes"
         self.duplicateCrashesDir = storageDir + "/crashes/duplicates"
         self.interestingDir = storageDir + "/interesting"
         self.stateFile = storageDir + "/state.json"
-        
+
         self.stateExportInterval = stateExportInterval
-        
+
         self.fuzzer = fuzzer
         self.logger = fuzzer.makeLogger(withLabel: "Storage")
+    }
 
+    public func initialize(with fuzzer: Fuzzer) {
         do {
             try FileManager.default.createDirectory(atPath: crashesDir, withIntermediateDirectories: true)
             try FileManager.default.createDirectory(atPath: duplicateCrashesDir, withIntermediateDirectories: true)

            let code = fuzzer.lifter.lift(ev.program)
            self.storeProgram(code, to: fileURL)
        }
        
        fuzzer.events.InterestingProgramFound.observe { ev in
            let filename = "sample_\(String(currentMillis())).js"
            let fileURL = URL(fileURLWithPath: "\(self.interestingDir)/\(filename)")
            let code = fuzzer.lifter.lift(ev.program, withOptions: .dumpTypes)
            self.storeProgram(code, to: fileURL)
        }
        
        // If enabled, export the current fuzzer state to disk in regular intervals.
        if let interval = stateExportInterval {
            fuzzer.timers.scheduleTask(every: interval, saveState)
            fuzzer.events.Shutdown.observe(saveState)
        }
    }
    
    private func storeProgram(_ code: String, to url: URL) {
        do {
            try code.write(to: url, atomically: false, encoding: String.Encoding.utf8)

        } catch {
            logger.fatal("Failed to create storage directories. Is \(storageDir) writable by the current user?")
        }

        fuzzer.events.CrashFound.observe { ev in
            let filename = "crash_\(String(currentMillis()))_\(ev.pid)_\(ev.behaviour.rawValue)_\(ev.signal).js"
            let fileURL: URL
            if ev.isUnique {
