     }
     
     deinit {
-        for f in frames {
-            f.clean()
+        if dataOwner == nil { // Only clean when self owns the data
+            for f in frames {
+                f.clean()
+            }
         }
     }
 }


public class APNGImage {

    public var duration: NSTimeInterval {
        return frames.reduce(0.0) {
            $0 + $1.duration

        self.bitDepth = bitDepth
        self.repeatCount = repeatCount
        self.firstFrameHidden = hidden
        dataOwner = nil
    }
    
    init(apng: APNGImage) {
        
        dataOwner = apng
        
        self.bitDepth = apng.bitDepth
        self.internalSize = apng.internalSize
        self.scale = apng.scale
        self.repeatCount = apng.repeatCount
        self.firstFrameHidden = apng.firstFrameHidden

        self.frames = apng.frames
    }
    
    public convenience init?(named imageName: String) {
