Merge branch 'master' of ssh://git.eclipse.org/gitroot/orion/org.eclipse.orion.client
diff --git a/bundles/org.eclipse.orion.client.core/web/js-tests/serviceRegistry/testcase.js b/bundles/org.eclipse.orion.client.core/web/js-tests/serviceRegistry/testcase.js
index f264ae1..b12a660 100644
--- a/bundles/org.eclipse.orion.client.core/web/js-tests/serviceRegistry/testcase.js
+++ b/bundles/org.eclipse.orion.client.core/web/js-tests/serviceRegistry/testcase.js
@@ -25,33 +25,31 @@
 			test : 1
 		});
 		var reference = registration.getServiceReference();
-		assert.equal("testRegister", reference.getProperty("service.names")[0]);
+		assert.equal("testRegister", reference.getProperty("objectClass")[0]);
 		assert.equal(1, reference.getProperty("test"));
 
-		assert.equal(0, count);
+		assert.equal(count, 0);
 		var service1 = registry.getService("testRegister");
 		service1.test().then(function(newcount) {
 			count = newcount;
 		});
-
-		assert.equal(1, count);
+		assert.equal(count, 1);
 
 		var service2 = registry.getService(reference);
 		service2.test().then(function(newcount) {
 			count = newcount;
 		});
-		assert.equal(2, count);
+		assert.equal(count, 2);
 
 		// contrived
 		assert.equal(service1, service2);
 		registration.unregister();
-		assert.throws(function() {
+		assert["throws"](function() {
 			service2.test().then(function(newcount) {
 				count = newcount;
 			});
 		});
-		count++;
-		assert.equal(3, count);
+		assert.equal(count, 2);
 	};
 	
 	tests.testRegisterUnregisterMultipleServices = function() {
@@ -119,8 +117,8 @@
 		var srhandler = function() {
 			serviceRemovedCount++;
 		};
-		registry.addEventListener("serviceAdded", sahandler);
-		registry.addEventListener("serviceRemoved", srhandler);
+		registry.addEventListener("registered", sahandler);
+		registry.addEventListener("unregistering", srhandler);
 
 		assert.equal(0, serviceAddedCount);
 		assert.equal(0, serviceRemovedCount);
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/EventTarget.js b/bundles/org.eclipse.orion.client.core/web/orion/EventTarget.js
index 4701939..4064293 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/EventTarget.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/EventTarget.js
@@ -11,14 +11,13 @@
  *******************************************************************************/

 /*global define console*/

 

-define(['orion/Deferred'], function(Deferred) {

+define(function() {

 	/**

 	 * Creates an Event Target

 	 *

 	 * @name orion.EventTarget

 	 * @class Base for creating an Orion event target

 	 */

-

 	function EventTarget() {

 		this._namedListeners = {};

 	}

@@ -29,7 +28,7 @@
 		 * Dispatches a named event along with an arbitrary set of arguments. Any arguments after <code>eventName</code>

 		 * will be passed to the event listener(s).

 		 * @param {Object} event The event to dispatch. The event object MUST have a type field

-		 * @returns {Deferred} A deferred that resolves when all event listeners have been notified, and all async-aware

+		 * @returns {boolean} false if the event has been canceled and any associated default action should not be performed

 		 * listeners (if any) have resolved.

 		 */

 		dispatchEvent: function(event) {

@@ -37,31 +36,22 @@
 				throw new Error("unspecified type");

 			}

 			var listeners = this._namedListeners[event.type];

-			if (!listeners) {

-				var d = new Deferred();

-				d.resolve();

-				return d;

+			if (listeners) {

+				listeners.forEach(function(listener) {

+					try {

+						if (typeof listener === "function") {

+							listener(event);

+						} else {

+							listener.handleEvent(event);

+						}

+					} catch (e) {

+						if (typeof console !== 'undefined') {

+							console.log(e); // for now, probably should dispatch an ("error", e)

+						}

+					}			

+				});

 			}

-

-			var deferreds = [];

-			listeners.forEach(function(listener) {

-				try {

-					var listenerDeferred = (typeof listener === "function") ? listener(event) : listener.handleEvent(event);

-					if (listenerDeferred && typeof listenerDeferred.then === 'function') {

-						deferreds.push(listenerDeferred);

-					}

-				} catch (e) {

-					if (typeof console !== 'undefined') {

-						console.log(e); // for now, probably should dispatch an ("error", e)

-					}

-				}			

-			});

-

-			return Deferred.all(deferreds, function(e) {

-				if (typeof console !== 'undefined') {

-					console.log(e);

-				}

-			});

+			return !event.defaultPrevented;

 		},

 

 		/**

diff --git a/bundles/org.eclipse.orion.client.core/web/orion/edit/dispatcher.js b/bundles/org.eclipse.orion.client.core/web/orion/edit/dispatcher.js
index 229f3ad..a9a9225 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/edit/dispatcher.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/edit/dispatcher.js
@@ -27,14 +27,14 @@
 		var self = this;
 		this.listener = {
 			onServiceAdded: function(event) {
-				self._onServiceAdded(event.serviceReference, event.service);
+				self._onServiceAdded(event.serviceReference);
 			},
 			onServiceRemoved: function(event) {
-				self._onServiceRemoved(event.serviceReference, event.service);
+				self._onServiceRemoved(event.serviceReference);
 			}
 		};
-		this.serviceRegistry.addEventListener("serviceAdded", this.listener.onServiceAdded); //$NON-NLS-0$
-		this.serviceRegistry.addEventListener("serviceRemoved", this.listener.onServiceRemoved); //$NON-NLS-0$
+		this.serviceRegistry.addEventListener("registered", this.listener.onServiceAdded); //$NON-NLS-0$
+		this.serviceRegistry.addEventListener("unregistering", this.listener.onServiceRemoved); //$NON-NLS-0$
 		this._init();
 	}
 	Dispatcher.prototype = /** @lends orion.edit.Dispatcher.prototype */ {
@@ -90,7 +90,7 @@
 			this.serviceReferences[serviceId].push([textView, type, listener]);
 			textView.addEventListener(type, listener);
 		},
-		_onServiceRemoved: function(serviceReference, service) {
+		_onServiceRemoved: function(serviceReference) {
 			var serviceId = serviceReference.getProperty('service.id');
 			var serviceReferences = this.serviceReferences[serviceId];
 			if (serviceReferences) {
@@ -103,8 +103,8 @@
 				delete this.serviceReferences[serviceId];
 			}
 		},
-		_onServiceAdded: function(serviceReference, service) {
-			if (serviceReference.getName() === "orion.edit.model") { //$NON-NLS-0$
+		_onServiceAdded: function(serviceReference) {
+			if (serviceReference.getProperty("objectClass").indexOf("orion.edit.model") !== -1) { //$NON-NLS-0$
 				this._wireServiceReference(serviceReference);
 			}
 		},
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js b/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js
index 58ff790..68a07ee 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/searchAndReplace/textSearcher.js
@@ -185,7 +185,8 @@
 				evt.cancelBubble = true;
 				return false;
 			}
-			if((ctrlKeyOnly && evt.keyCode === 75/*"k"*/ ) || evt.keyCode === 13/*enter*/ ){
+			//We can't use ctrlKeyOnly on "k" because ctrl+shift+k means find previous match when the find bar gets focus
+			if(((this.isMac ? evt.metaKey : evt.ctrlKey) && !evt.altKey && evt.keyCode === 75/*"k"*/) || evt.keyCode === 13/*enter*/){
 				if( evt.stopPropagation ) { 
 					evt.stopPropagation(); 
 				}
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/serviceTracker.js b/bundles/org.eclipse.orion.client.core/web/orion/serviceTracker.js
index 36b15b3..22b7910 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/serviceTracker.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/serviceTracker.js
@@ -57,8 +57,8 @@
 				throw 'Already closed'; //$NON-NLS-0$
 			}
 			state = CLOSED;
-			serviceRegistry.removeEventListener('serviceAdded', addedListener); //$NON-NLS-0$
-			serviceRegistry.removeEventListener('serviceRemoved', removedListener); //$NON-NLS-0$
+			serviceRegistry.removeEventListener('registered', addedListener); //$NON-NLS-0$
+			serviceRegistry.removeEventListener('unregistering', removedListener); //$NON-NLS-0$
 			addedListener = null;
 			removedListener = null;
 			var self = this;
@@ -99,7 +99,7 @@
 				if (isTrackable(event.serviceReference)) {
 					add.call(self, event.serviceReference);
 					if (typeof self.onServiceAdded === 'function') {
-						return self.onServiceAdded(event.serviceReference, event.service);
+						return self.onServiceAdded(event.serviceReference, self.serviceRegistry.getService(event.serviceReference));
 					}
 				}
 			};
@@ -108,8 +108,8 @@
 					remove.call(self, event.serviceReference);
 				}
 			};
-			serviceRegistry.addEventListener('serviceAdded', addedListener); //$NON-NLS-0$
-			serviceRegistry.addEventListener('serviceRemoved', removedListener); //$NON-NLS-0$
+			serviceRegistry.addEventListener('registered', addedListener); //$NON-NLS-0$
+			serviceRegistry.addEventListener('unregistering', removedListener); //$NON-NLS-0$
 			serviceRegistry.getServiceReferences(serviceName).forEach(function(serviceRef) {
 				add.call(self, serviceRef);
 			});
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/serviceregistry.js b/bundles/org.eclipse.orion.client.core/web/orion/serviceregistry.js
index 0dca084..10ccd16 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/serviceregistry.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/serviceregistry.js
@@ -23,10 +23,11 @@
 	 * @param {Object} properties A JSON object containing the service's declarative properties
 	 */
 
-	function ServiceReference(serviceId, names, properties) {
+	function ServiceReference(serviceId, objectClass, properties) {
 		this._properties = properties || {};
+		this._properties.objectClass = objectClass;
 		this._properties["service.id"] = serviceId;
-		this._properties["service.names"] = names;
+		this._properties["service.names"] = objectClass;
 	}
 
 	ServiceReference.prototype = /** @lends orion.serviceregistry.ServiceReference.prototype */
@@ -70,6 +71,7 @@
 		this._serviceReference = serviceReference;
 		this._internalRegistry = internalRegistry;
 	}
+
 	ServiceRegistration.prototype = /** @lends orion.serviceregistry.ServiceRegistration.prototype */
 	{
 		/**
@@ -83,18 +85,23 @@
 		 * Returns a reference to this registered service.
 		 */
 		getServiceReference: function() {
+			if (!this._internalRegistry.isRegistered(this._serviceId)) {
+				throw new Error("already unregistered");
+			}
 			return this._serviceReference;
 		}
 	};
 	ServiceRegistration.prototype.constructor = ServiceRegistration;
 
-	function DeferredService(implementation) {
-		var method;
+	function DeferredService(implementation, isRegistered) {
 
 		function _createServiceCall(methodName) {
 			return function() {
 					var d;
 					try {
+						if (!isRegistered()) {
+							throw new Error("Service was unregistered");
+						}
 						var result = implementation[methodName].apply(implementation, Array.prototype.slice.call(arguments));
 						if (result && typeof result.then === "function") {
 							return result;
@@ -110,6 +117,7 @@
 			};
 		}
 
+		var method;
 		for (method in implementation) {
 			if (typeof implementation[method] === 'function') {
 				this[method] = _createServiceCall(method);
@@ -117,26 +125,9 @@
 		}
 	}
 	
-	function RegisteredService(serviceId, implementation, internalRegistry, registered) {
-		var method;
-
-		function _createServiceCall(methodName) {
-			return function() {
-				var args = arguments;
-				return registered.then(function() {
-					if (internalRegistry.isRegistered(serviceId)) {
-						return implementation[methodName].apply(implementation, Array.prototype.slice.call(args));
-					}
-					throw new Error("Service was unregistered");
-				});
-			};
-		}
-
-		for (method in implementation) {
-			if (typeof implementation[method] === 'function') {
-				this[method] = _createServiceCall(method);
-			}
-		}
+	function ServiceEvent(type, serviceReference) {
+		this.type = type;
+		this.serviceReference = serviceReference;
 	}
 
 	/**
@@ -148,37 +139,39 @@
 
 	function ServiceRegistry() {
 		this._entries = [];
-		this._namedReferences = {};
+		this._typedReferences = {};
 		this._serviceEventTarget = new EventTarget();
-		var that = this;
+		var _this = this;
 		this._internalRegistry = {
 			isRegistered: function(serviceId) {
-				return that._entries[serviceId] ? true : false;
+				return _this._entries[serviceId] ? true : false;
 			},
 			unregisterService: function(serviceId) {
-				var entry = that._entries[serviceId];
-				if (entry) {
-					var reference = entry.reference;
-					var names = reference.getProperty("service.names");
-					names.forEach(function(name) {
-						var namedReferences = that._namedReferences[name];
-						for (var i = 0; i < namedReferences.length; i++) {
-							if (namedReferences[i] === reference) {
-								if (namedReferences.length === 1) {
-									delete that._namedReferences[name];
-								} else {
-									namedReferences.splice(i, 1);
-								}
-								break;
+				var entry = _this._entries[serviceId];
+				if (!entry) {
+					throw new Error("already unregistered");
+				}				
+				var reference = entry.reference;
+				_this._serviceEventTarget.dispatchEvent(new ServiceEvent("unregistering", reference));
+				_this._entries[serviceId] = null;
+				var objectClass = reference.getProperty("objectClass");
+				objectClass.forEach(function(type) {
+					var typedReferences = _this._typedReferences[type];
+					for (var i = 0; i < typedReferences.length; i++) {
+						if (typedReferences[i] === reference) {
+							if (typedReferences.length === 1) {
+								delete _this._typedReferences[type];
+							} else {
+								typedReferences.splice(i, 1);
 							}
+							break;
 						}
-					});
-					that._entries[serviceId] = null;
-					that._serviceEventTarget.dispatchEvent({type:"serviceRemoved", serviceReference: reference, service: entry.service});
-				}
+					}
+				});
 			}
 		};
 	}
+	
 	ServiceRegistry.prototype = /** @lends orion.serviceregistry.ServiceRegistry.prototype */
 	{
 
@@ -186,10 +179,10 @@
 		 * Returns the service with the given name or reference.
 		 * @param {String|orion.serviceregistry.ServiceReference} nameOrServiceReference The service name or a service reference
 		 */
-		getService: function(nameOrServiceReference) {
+		getService: function(typeOrServiceReference) {
 			var service;
-			if (typeof nameOrServiceReference === "string") {
-				var references = this._namedReferences[nameOrServiceReference];
+			if (typeof typeOrServiceReference === "string") {
+				var references = this._typedReferences[typeOrServiceReference];
 				if (references) {
 					references.some(function(reference) {
 						service = this._entries[reference.getProperty("service.id")].service;
@@ -197,7 +190,10 @@
 					}, this);
 				}
 			} else {
-				service = this._entries[nameOrServiceReference.getProperty("service.id")].service;
+				var entry = this._entries[typeOrServiceReference.getProperty("service.id")];
+				if (entry) {
+					service = entry.service;
+				}
 			}
 			return service || null;
 		},
@@ -209,7 +205,7 @@
 		 */
 		getServiceReferences: function(name) {
 			if (name) {
-				return this._namedReferences[name] ? this._namedReferences[name] : [];
+				return this._typedReferences[name] ? this._typedReferences[name] : [];
 			}
 			var result = [];
 			this._entries.forEach(function(entry) {
@@ -221,36 +217,37 @@
 		},
 		/**
 		 * Registers a service with this registry.
-		 * @param {String|String[]} names the names of the service being registered
-		 * @param {Object} implementation The service implementation
+		 * @param {String|String[]} types the types of the service being registered
+		 * @param {Object} service The service implementation
 		 * @param {Object} properties A JSON collection of declarative service properties
 		 * @returns {orion.serviceregistry.ServiceRegistration} A service registration object for the service.
 		 */
-		registerService: function(names, implementation, properties) {
-			var serviceId = this._entries.length;
-			
-			if (typeof(names) === "string") {
-				names = [names];
+		registerService: function(types, service, properties) {
+			if (typeof service === "undefined" ||  service === null) {
+				throw new Error("invalid service");
 			}
 			
-			var deferredService = new DeferredService(implementation);
-			var registered = new Deferred();
-			var registeredService = new RegisteredService(serviceId, deferredService, this._internalRegistry, registered);
+			if (typeof types === "string") {
+				types = [types];
+			} else if (!Array.isArray(types)) {
+				types = [];
+			}
 			
-			var reference = new ServiceReference(serviceId, names, properties);
-			var namedReferences = this._namedReferences;
-			names.forEach(function(name) {
-				namedReferences[name] = namedReferences[name] || [];
-				namedReferences[name].push(reference);
+			var serviceId = this._entries.length;			
+			var reference = new ServiceReference(serviceId, types, properties);
+			var typedReferences = this._typedReferences;
+			types.forEach(function(name) {
+				typedReferences[name] = typedReferences[name] || [];
+				typedReferences[name].push(reference);
 			});
-			
+			var deferredService = new DeferredService(service, this._internalRegistry.isRegistered.bind(null, serviceId));
 			this._entries.push({
 				reference: reference,
-				service: registeredService
+				service: deferredService
 			});
-	
-			this._serviceEventTarget.dispatchEvent({type:"serviceAdded", serviceReference: reference, service:deferredService}).then(registered.resolve);
-			return new ServiceRegistration(serviceId, reference, this._internalRegistry);
+			var internalRegistry = this._internalRegistry;
+			this._serviceEventTarget.dispatchEvent(new ServiceEvent("registered", reference));
+			return new ServiceRegistration(serviceId, reference, internalRegistry);
 		},
 
 		/**
@@ -275,8 +272,6 @@
 
 	//return the module exports
 	return {
-		ServiceReference: ServiceReference,
-		ServiceRegistration: ServiceRegistration,
 		ServiceRegistry: ServiceRegistry
 	};
 });
\ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/widgets/RegistryTree.js b/bundles/org.eclipse.orion.client.core/web/orion/widgets/RegistryTree.js
deleted file mode 100644
index 6f5fc7d..0000000
--- a/bundles/org.eclipse.orion.client.core/web/orion/widgets/RegistryTree.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * @license
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials are made 
- * available under the terms of the Eclipse Public License v1.0 
- * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
- * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). 
- * 
- * Contributors: IBM Corporation - initial API and implementation
- ******************************************************************************/
-
-/*jslint forin:true*/
-/*global dijit dojo eclipse widgets*/
-
-define(['i18n!orion/widgets/nls/messages', 'dojo', 'dijit', 'dojo/data/ItemFileReadStore', 'dijit/Tree', 'dijit/tree/TreeStoreModel'], function(messages, dojo, dijit) {
-
-// TODO re-implement mayHaveChildren so leaves never have expando icons
-dojo.declare("orion.widgets.RegistryTree", [dijit.Tree], { //$NON-NLS-0$
-	constructor: function(options) {
-		this.inherited(arguments);
-		this.registry = options && options.registry;
-		if (!this.registry) { throw "Option 'registry' is required"; } //$NON-NLS-0$
-		var registryData = this.buildRegistry(this.registry);
-		var store = new dojo.data.ItemFileReadStore({
-			data: {
-				identifier: "id", //$NON-NLS-0$
-				label: "label", //$NON-NLS-0$
-				items: registryData
-			}
-		});
-		//console.debug(JSON.stringify(registryData));
-		var model = new dijit.tree.TreeStoreModel({ store: store });
-		this.model = model;
-	},
-	/**
-	 * Parse the registry contents into a nice tree
-	 * @return {Array.<{{id:string, label:string, children:Array}}>} (The "children" property is optional)
-	 */
-	buildRegistry: function(registry) {
-		var plugins =  { id: "plugins", label: messages["Plug-ins"], children: this.buildPlugins("plugins", registry) }; //$NON-NLS-2$ //$NON-NLS-0$
-		return [ plugins ];
-	},
-	buildPlugins: function(prefix, registry) {
-		var nodes = [];
-		var plugins = registry.getPlugins();
-		for (var i=0; i < plugins.length; i++) {
-			var newPrefix = prefix + "|" + plugins[i].getLocation(); //$NON-NLS-0$
-			nodes.push({
-				plugin: plugins[i],
-				id: newPrefix,
-				label: plugins[i].getLocation() + (typeof plugins[i].getData().services === "undefined" ? messages[" <No available services or timed out, check URL and try reloading>"] : ""), //$NON-NLS-0$
-				children: [this.buildServices(newPrefix, plugins[i].getServiceReferences())]
-			});
-		}
-		return nodes;
-	},
-	buildProperties: function(prefix, /** Object */ reference) {
-		var newPrefix = prefix + "|properties", //$NON-NLS-0$
-		    data = [];
-		
-		var propertyNames = reference.getPropertyKeys();
-		for (var i =0; i < propertyNames.length; i++) {
-			var key = propertyNames[i];
-			var value = reference.getProperty(key);
-			data.push({
-				id: newPrefix + "|" + key, //$NON-NLS-0$
-				label: key + " = " + value //$NON-NLS-0$
-			});
-		}
-		var result = {
-			id: newPrefix,
-			label: messages["Properties"],
-			children: data
-		};
-		if (data.length === 0) {
-			delete result.children; // looks nicer when empty
-		}
-		return result;
-	},
-	buildServices: function(prefix, /** Array */ references) {
-		var scope = this;
-		var data = [];
-		for (var i=0; i < references.length; i++) {
-			var reference = references[i],
-			    servicePrefix = prefix + "|services|" + i, //$NON-NLS-0$
-			    serviceName = reference.getName();
-			data.push({
-				id: servicePrefix,
-				label: serviceName + messages[" (Service Id: "] + reference.getServiceId() + ")", //$NON-NLS-1$
-				children: [this.buildProperties(servicePrefix, reference)]
-			});
-		}
-		return {
-			id: prefix + "|services", //$NON-NLS-0$
-			label: messages["Services"],
-			children: data
-		};
-	},
-	getSelectedPlugins: function() {
-		if (this.selectedNodes.length === 0) {
-			return [];
-		}
-		var plugins = [];
-		for (var i=0; i<this.selectedNodes.length; i++) {
-			if (this.selectedNodes[i].item.plugin) {
-				// each item node's properties are actually kept in a single item array.
-				// I have no idea why, something with the TreeStoreModel????
-				plugins.push(this.selectedNodes[i].item.plugin[0]);
-			}
-		}
-		return plugins;
-	}
-});
-});
-
-
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/asyncStyler.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/asyncStyler.js
index a8028c7..fe59426 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/asyncStyler.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/asyncStyler.js
@@ -59,19 +59,19 @@
 				onStyleReady: function(e) {
 					self.onStyleReady(e);
 				},
-				onServiceAdded: function(serviceRef, service) {
-					self.onServiceAdded(serviceRef, service);
+				onServiceAdded: function(serviceEvent) {
+					self.onServiceAdded(serviceEvent.serviceReference, self.serviceRegistry.getService(serviceEvent.serviceReference));
 				},
-				onServiceRemoved: function(serviceRef, service) {
-					self.onServiceRemoved(serviceRef, service);
+				onServiceRemoved: function(serviceEvent) {
+					self.onServiceRemoved(serviceEvent.serviceReference, self.serviceRegistry.getService(serviceEvent.serviceReference));
 				}
 			};
 			textView.addEventListener("ModelChanging", this.listener.onModelChanging);
 			textView.addEventListener("ModelChanged", this.listener.onModelChanged);
 			textView.addEventListener("Destroy", this.listener.onDestroy);
 			textView.addEventListener("LineStyle", this.listener.onLineStyle);
-			serviceRegistry.addEventListener("serviceAdded", this.listener.onServiceAdded);
-			serviceRegistry.addEventListener("serviceRemoved", this.listener.onServiceRemoved);
+			serviceRegistry.addEventListener("registered", this.listener.onServiceAdded);
+			serviceRegistry.addEventListener("unregistering", this.listener.onServiceRemoved);
 
 			var serviceRefs = serviceRegistry.getServiceReferences(SERVICE_NAME);
 			for (var i = 0; i < serviceRefs.length; i++) {
@@ -99,8 +99,8 @@
 				this.services = null;
 			}
 			if (this.serviceRegistry) {
-				this.serviceRegistry.removeEventListener("serviceAdded", this.listener.onServiceAdded);
-				this.serviceRegistry.removeEventListener("onServiceRemoved", this.listener.onServiceRemoved);
+				this.serviceRegistry.removeEventListener("registered", this.listener.onServiceAdded);
+				this.serviceRegistry.removeEventListener("unregistering", this.listener.onServiceRemoved);
 				this.serviceRegistry = null;
 			}
 			this.listener = null;
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/textview/i18n.js b/bundles/org.eclipse.orion.client.editor/web/orion/textview/i18n.js
index e8a8227..6a4c037 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/textview/i18n.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/textview/i18n.js
@@ -12,7 +12,7 @@
 /*global define */

 define({

 	load: function(name, parentRequire, onLoad, config) {

-		if (parentRequire.specified("orion/bootstrap")) { //$NON-NLS-0$

+		if (parentRequire.specified && parentRequire.specified("orion/bootstrap")) { //$NON-NLS-0$

 			parentRequire(["orion/i18n!" + name], function(languages) { //$NON-NLS-0$

 				onLoad(languages);

 			});

diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js
index a34004c..77865cd 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js
@@ -85,7 +85,7 @@
 		}
 		
 		// display prompt checkbox only when it makes sense
-		var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+		var gitCredentialsStorage = new GitCredentialsStorage();
 		if(!gitCredentialsStorage.isEnabled()){
 			dojo.style(this.gitSavePrivateKey, "display", "none");
 			dojo.style(this.gitSavePrivateKeyLabel, "display", "none");
@@ -131,18 +131,20 @@
 		var process = function(pKey){
 			if(self._sshService){
 				self._sshService.getKnownHosts().then(function(knownHosts){
-					if(self.options.func)
+					if(self.options.func) {
 						self.options.func({ gitSshUsername: self.gitSshUsername.value, gitSshPassword: self.isSshPassword.checked ? self.gitSshPassword.value : "",
 							gitPrivateKey: self.isPrivateKey.checked ? pKey : "", gitPassphrase: self.isPrivateKey.checked ? self.gitPassphrase.value: "", //$NON-NLS-0$
 							knownHosts: knownHosts});
+						}
 					delete self.options.func; //prevent performing this action twice (IE)
 				});
 				
 			}else{
-				if(self.options.func)
+				if(self.options.func) {
 					self.options.func({ gitSshUsername: self.gitSshUsername.value, gitSshPassword: self.gitSshPassword.value,
 						gitPrivateKey: pKey, gitPassphrase: self.gitPassphrase.value,
 						knownHosts: self.gitSshKnownHosts.value});
+					}
 				delete self.options.func; //prevent performing this action twice (IE)
 			}
 		};
@@ -164,7 +166,7 @@
 					
 					process(loadedPrivateKey);
 				};
-			})(this.privateKeyFile);
+			}(this.privateKeyFile));
 			
 			reader.readAsText(this.privateKeyFile);
 		} else if(loadedPrivateKey){