module('lively.CanvasExptCoreFixes').requires('lively.Core').toRun(function() {

NodeFactory.create = function(name, attributes) {
		    var element = emudom.document.createElementNS(Namespace.SVG, name);
		    //return this.createNS(Namespace.SVG, name, attributes);  // doesn't work
		    return NodeFactory.extend(null, element, attributes);
		};
debugger
		WorldMorph.addMethods({
			setChangeSet: function(cs) {
				// FIXME
				// cs.addHookTo(cs.findOrCreateDefNodeOfWorld(this.rawNode));
			},

		    displayOnCanvas: function(canvas) {
				// this.remove();

				//canvas.appendChild(this.rawNode);
				// otherwise we may be 
		        var hand = this.addHand(new HandMorph(true));
				WorldMorph.currentWorld = this; // this conflicts with mutliple worlds
		        this.onEnter(); 

				this.enterCount ++;
		    },

		    addHand: function(hand) {
		        if (this.hands.length > 0 && !this.hands.first())
		            this.hands.shift(); // FIXME: Quick bugfix. When deserializing the world the hands.first() is sometimes undefined
		        this.hands.push(hand);
		        hand.owner = this;
		        hand.registerForEvents(this);
		        hand.registerForEvents(hand);
		        hand.layoutChanged();

		        Event.keyboardEvents.forEach(function(each) {
		            document.documentElement.addEventListener(each, hand, hand.handleOnCapture);
		        });

		        //this.rawNode.parentNode.appendChild(hand.rawNode);
				return hand;
		    }

		});

		lively.data.Wrapper.addMethods({
		    reference: function() {
				if (!this.refcount) {
			    	if (!this.id()) {
						this.setId(this.newId());
			    	}
			    	//this.dictionary().appendChild(this.rawNode);
			    	this.refcount = 1; 
			    	return;
				}
				this.refcount ++;
		    },
			ensureInDictionary: function() { }
		});

}) // end of module