     }
     
     func shakeHead() {
-        var layer = contentView.image.layerWithIdentifier("head")
-        
-        var animation = CABasicAnimation(keyPath: "transform.rotation.z")
+        if let layer = contentView?.image.layerWithIdentifier("head") {
+        
+        let animation = CABasicAnimation(keyPath: "transform.rotation.z")
         animation.duration = 0.25
         animation.autoreverses = true
         animation.repeatCount = 100000;

                labelParseTime = tmpLabel
            }
            /** Workaround for Apple 10 years old bug in OS X that they ported to iOS :( */
            labelParseTime!.frame = CGRectMake( 0, 0, self.contentView.bounds.size.width, 20.0 );
            
            contentView.addSubview(labelParseTime!)
            
            /** set the border for new item */
            self.contentView.showBorder = false;
            
            /** Move the gesture recognizer onto the new one */
            if( tapGestureRecognizer == nil ) {
                self.tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "handleTapGesture:") ;
            }
            contentView.addGestureRecognizer(tapGestureRecognizer)
            
            scrollViewForSVG.addSubview(contentView)
            scrollViewForSVG.contentSize = contentView.frame.size
            
            var screenToDocumentSizeRatio = self.scrollViewForSVG.frame.size.width / self.contentView.frame.size.width;
            
            self.scrollViewForSVG.minimumZoomScale = min( 1, screenToDocumentSizeRatio );
            self.scrollViewForSVG.maximumZoomScale = max( 1, screenToDocumentSizeRatio );
            
            title = self.name;
            labelParseTime!.text = NSString(format:"%@ (parsed: %.2f secs, rendered: %.2f secs)", name, endParseTime.timeIntervalSinceDate(startParseTime), self.contentView.timeIntervalForLastReRenderOfSVGFromMemory)
            
            /** Fast image view renders asynchronously, so we have to wait for a callback that its finished a render... */
            contentView.addObserver(self, forKeyPath: "timeIntervalForLastReRenderOfSVGFromMemory", options: NSKeyValueObservingOptions(0), context: nil)
            
            /**
            EXAMPLE:

                if SHOW_DEBUG_INFO_ON_EACH_TAPPED_LAYER {
                    /** mtrubnikov's code for adding a text overlay showing exactly what you tapped
                    */
                    var textToDraw: String = NSString(format: "%@ (%@): {%.1f, %.1f} {%.1f, %.1f}", (hitLayer?.name ?? ""), NSStringFromClass(hitLayer!.dynamicType), lastTappedLayer!.frame.origin.x, lastTappedLayer!.frame.origin.y, lastTappedLayer!.frame.size.width, lastTappedLayer!.frame.size.height);
                    
                    var fontToDraw = UIFont(name: "Helvetica", size: 14)!
                    let sizeOfTextRect = textToDraw.sizeWithAttributes([NSFontAttributeName: fontToDraw])
