Index: annotator_files/lib/annotator.js
===================================================================
--- annotator_files/lib/annotator.js	(revision 3)
+++ annotator_files/lib/annotator.js	(revision 4)
@@ -1,6 +1,7 @@
-var Annotator, util, _Annotator,
+// Generated by CoffeeScript 1.3.3
+var Annotator, g, util, _Annotator, _ref,
   __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 util = {
@@ -17,4 +18,21 @@
     })();
   },
+  maxZIndex: function($elements) {
+    var all, el;
+    all = (function() {
+      var _i, _len, _results;
+      _results = [];
+      for (_i = 0, _len = $elements.length; _i < _len; _i++) {
+        el = $elements[_i];
+        if ($(el).css('position') === 'static') {
+          _results.push(-1);
+        } else {
+          _results.push(parseInt($(el).css('z-index'), 10) || -1);
+        }
+      }
+      return _results;
+    })();
+    return Math.max.apply(Math, all);
+  },
   mousePosition: function(e, offsetEl) {
     var offset;
@@ -44,5 +62,4 @@
 
   Annotator.prototype.html = {
-    hl: '<span class="annotator-hl"></span>',
     adder: '<div class="annotator-adder"><button>' + _t('Annotate') + '</button></div>',
     wrapper: '<div class="annotator-wrapper"></div>'
@@ -69,27 +86,39 @@
   function Annotator(element, options) {
     this.onDeleteAnnotation = __bind(this.onDeleteAnnotation, this);
+
     this.onEditAnnotation = __bind(this.onEditAnnotation, this);
+
     this.onAdderClick = __bind(this.onAdderClick, this);
+
     this.onAdderMousedown = __bind(this.onAdderMousedown, this);
+
     this.onHighlightMouseover = __bind(this.onHighlightMouseover, this);
+
     this.checkForEndSelection = __bind(this.checkForEndSelection, this);
+
     this.checkForStartSelection = __bind(this.checkForStartSelection, this);
+
     this.clearViewerHideTimer = __bind(this.clearViewerHideTimer, this);
+
     this.startViewerHideTimer = __bind(this.startViewerHideTimer, this);
+
     this.showViewer = __bind(this.showViewer, this);
+
     this.onEditorSubmit = __bind(this.onEditorSubmit, this);
+
     this.onEditorHide = __bind(this.onEditorHide, this);
+
     this.showEditor = __bind(this.showEditor, this);
-    var name, src, _ref;
     Annotator.__super__.constructor.apply(this, arguments);
     this.plugins = {};
-    if (!Annotator.supported()) return this;
-    if (!this.options.readOnly) this._setupDocumentEvents();
+    if (!Annotator.supported()) {
+      return this;
+    }
+    if (!this.options.readOnly) {
+      this._setupDocumentEvents();
+    }
     this._setupWrapper()._setupViewer()._setupEditor();
-    _ref = this.html;
-    for (name in _ref) {
-      src = _ref[name];
-      if (name !== 'wrapper') this[name] = $(src).appendTo(this.wrapper).hide();
-    }
+    this._setupDynamicStyle();
+    this.adder = $(this.html.adder).appendTo(this.wrapper).hide();
   }
 
@@ -147,4 +176,26 @@
   };
 
+  Annotator.prototype._setupDynamicStyle = function() {
+    var max, sel, style, x;
+    style = $('#annotator-dynamic-style');
+    if (!style.length) {
+      style = $('<style id="annotator-dynamic-style"></style>').appendTo(document.head);
+    }
+    sel = '*' + ((function() {
+      var _i, _len, _ref, _results;
+      _ref = ['adder', 'outer', 'notice', 'filter'];
+      _results = [];
+      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+        x = _ref[_i];
+        _results.push(":not(.annotator-" + x + ")");
+      }
+      return _results;
+    })()).join('');
+    max = util.maxZIndex($(document.body).find(sel));
+    max = Math.max(max, 1000);
+    style.text([".annotator-adder, .annotator-outer, .annotator-notice {", "  z-index: " + (max + 20) + ";", "}", ".annotator-filter {", "  z-index: " + (max + 10) + ";", "}"].join("\n"));
+    return this;
+  };
+
   Annotator.prototype.getSelectedRanges = function() {
     var browserRange, i, normedRange, r, ranges, rangesToIgnore, selection, _i, _len;
@@ -154,11 +205,13 @@
     if (!selection.isCollapsed) {
       ranges = (function() {
-        var _ref, _results;
+        var _i, _ref, _results;
         _results = [];
-        for (i = 0, _ref = selection.rangeCount; 0 <= _ref ? i < _ref : i > _ref; 0 <= _ref ? i++ : i--) {
+        for (i = _i = 0, _ref = selection.rangeCount; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
           r = selection.getRangeAt(i);
           browserRange = new Range.BrowserRange(r);
           normedRange = browserRange.normalize().limit(this.wrapper[0]);
-          if (normedRange === null) rangesToIgnore.push(r);
+          if (normedRange === null) {
+            rangesToIgnore.push(r);
+          }
           _results.push(normedRange);
         }
@@ -172,5 +225,7 @@
     }
     return $.grep(ranges, function(range) {
-      if (range) selection.addRange(range.toRange());
+      if (range) {
+        selection.addRange(range.toRange());
+      }
       return range;
     });
@@ -185,27 +240,29 @@
 
   Annotator.prototype.setupAnnotation = function(annotation, fireEvents) {
-    var normed, normedRanges, r, sniffed, _i, _len;
-    if (fireEvents == null) fireEvents = true;
+    var normed, normedRanges, r, root, _i, _j, _len, _len1, _ref;
+    if (fireEvents == null) {
+      fireEvents = true;
+    }
+    root = this.wrapper[0];
     annotation.ranges || (annotation.ranges = this.selectedRanges);
-    normedRanges = (function() {
-      var _i, _len, _ref, _results;
-      _ref = annotation.ranges;
-      _results = [];
-      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-        r = _ref[_i];
-        if (!(r != null)) continue;
-        sniffed = Range.sniff(r);
-        _results.push(sniffed.normalize(this.wrapper[0]));
-      }
-      return _results;
-    }).call(this);
-    normedRanges = $.grep(normedRanges, function(range) {
-      return range !== null;
-    });
+    normedRanges = [];
+    _ref = annotation.ranges;
+    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+      r = _ref[_i];
+      try {
+        normedRanges.push(Range.sniff(r).normalize(root));
+      } catch (e) {
+        if (e instanceof Range.RangeError) {
+          this.publish('rangeNormalizeFail', [annotation, r, e]);
+        } else {
+          throw e;
+        }
+      }
+    }
     annotation.quote = [];
     annotation.ranges = [];
     annotation.highlights = [];
-    for (_i = 0, _len = normedRanges.length; _i < _len; _i++) {
-      normed = normedRanges[_i];
+    for (_j = 0, _len1 = normedRanges.length; _j < _len1; _j++) {
+      normed = normedRanges[_j];
       annotation.quote.push($.trim(normed.text()));
       annotation.ranges.push(normed.serialize(this.wrapper[0], '.annotator-hl'));
@@ -214,5 +271,7 @@
     annotation.quote = annotation.quote.join(' / ');
     $(annotation.highlights).data('annotation', annotation);
-    if (fireEvents) this.publish('annotationCreated', [annotation]);
+    if (fireEvents) {
+      this.publish('annotationCreated', [annotation]);
+    }
     return annotation;
   };
@@ -238,8 +297,12 @@
     var clone, loader,
       _this = this;
-    if (annotations == null) annotations = [];
+    if (annotations == null) {
+      annotations = [];
+    }
     loader = function(annList) {
       var n, now, _i, _len;
-      if (annList == null) annList = [];
+      if (annList == null) {
+        annList = [];
+      }
       now = annList.splice(0, 10);
       for (_i = 0, _len = now.length; _i < _len; _i++) {
@@ -250,5 +313,5 @@
         return setTimeout((function() {
           return loader(annList);
-        }), 1);
+        }), 10);
       } else {
         return _this.publish('annotationsLoaded', [clone]);
@@ -256,5 +319,7 @@
     };
     clone = annotations.slice();
-    if (annotations.length) loader(annotations);
+    if (annotations.length) {
+      loader(annotations);
+    }
     return this;
   };
@@ -268,7 +333,11 @@
   };
 
-  Annotator.prototype.highlightRange = function(normedRange) {
-    var node, white, _i, _len, _ref, _results;
+  Annotator.prototype.highlightRange = function(normedRange, cssClass) {
+    var hl, node, white, _i, _len, _ref, _results;
+    if (cssClass == null) {
+      cssClass = 'annotator-hl';
+    }
     white = /^\s*$/;
+    hl = $("<span class='" + cssClass + "'></span>");
     _ref = normedRange.textNodes();
     _results = [];
@@ -276,8 +345,21 @@
       node = _ref[_i];
       if (!white.test(node.nodeValue)) {
-        _results.push($(node).wrapAll(this.hl).parent().show()[0]);
+        _results.push($(node).wrapAll(hl).parent().show()[0]);
       }
     }
     return _results;
+  };
+
+  Annotator.prototype.highlightRanges = function(normedRanges, cssClass) {
+    var highlights, r, _i, _len;
+    if (cssClass == null) {
+      cssClass = 'annotator-hl';
+    }
+    highlights = [];
+    for (_i = 0, _len = normedRanges.length; _i < _len; _i++) {
+      r = normedRanges[_i];
+      $.merge(highlights, this.highlightRange(r, cssClass));
+    }
+    return highlights;
   };
 
@@ -304,4 +386,5 @@
     this.editor.element.css(location);
     this.editor.load(annotation);
+    this.publish('annotationEditorShown', [this.editor, annotation]);
     return this;
   };
@@ -348,5 +431,7 @@
     var container, range, _i, _len, _ref;
     this.mouseIsDown = false;
-    if (this.ignoreMouseup) return;
+    if (this.ignoreMouseup) {
+      return;
+    }
     this.selectedRanges = this.getSelectedRanges();
     _ref = this.selectedRanges;
@@ -354,5 +439,10 @@
       range = _ref[_i];
       container = range.commonAncestor;
-      if (this.isAnnotator(container)) return;
+      if ($(container).hasClass('annotator-hl')) {
+        container = $(container).parents('[class^=annotator-hl]')[0];
+      }
+      if (this.isAnnotator(container)) {
+        return;
+      }
     }
     if (event && this.selectedRanges.length) {
@@ -370,5 +460,7 @@
     var annotations;
     this.clearViewerHideTimer();
-    if (this.mouseIsDown || this.viewer.isShown()) return false;
+    if (this.mouseIsDown || this.viewer.isShown()) {
+      return false;
+    }
     annotations = $(event.target).parents('.annotator-hl').andSelf().map(function() {
       return $(this).data("annotation");
@@ -378,13 +470,39 @@
 
   Annotator.prototype.onAdderMousedown = function(event) {
-    if (event != null) event.preventDefault();
+    if (event != null) {
+      event.preventDefault();
+    }
     return this.ignoreMouseup = true;
   };
 
   Annotator.prototype.onAdderClick = function(event) {
-    var position;
-    if (event != null) event.preventDefault();
+    var highlights, position, r, ranges;
+    if (event != null) {
+      event.preventDefault();
+    }
     position = this.adder.position();
     this.adder.hide();
+    if (this.selectedRanges && this.selectedRanges.length) {
+      ranges = (function() {
+        var _i, _len, _ref, _results;
+        _ref = this.selectedRanges;
+        _results = [];
+        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+          r = _ref[_i];
+          _results.push(Range.sniff(r).normalize());
+        }
+        return _results;
+      }).call(this);
+      highlights = this.highlightRanges(ranges, 'annotator-hl annotator-hl-temporary');
+      this.editor.element.one('hide', function() {
+        var h, _i, _len, _results;
+        _results = [];
+        for (_i = 0, _len = highlights.length; _i < _len; _i++) {
+          h = highlights[_i];
+          _results.push($(h).replaceWith(h.childNodes));
+        }
+        return _results;
+      });
+    }
     return this.showEditor(this.createAnnotation(), position);
   };
@@ -420,4 +538,18 @@
 })(Delegator);
 
+g = util.getGlobal();
+
+if (!(((_ref = g.document) != null ? _ref.evaluate : void 0) != null)) {
+  $.getScript('http://assets.annotateit.org/vendor/xpath.min.js');
+}
+
+if (!(g.getSelection != null)) {
+  $.getScript('http://assets.annotateit.org/vendor/ierange.min.js');
+}
+
+if (!(g.JSON != null)) {
+  $.getScript('http://assets.annotateit.org/vendor/json2.min.js');
+}
+
 Annotator.$ = $;
 
Index: annotator_files/lib/class.js
===================================================================
--- annotator_files/lib/class.js	(revision 3)
+++ annotator_files/lib/class.js	(revision 4)
@@ -1,5 +1,6 @@
+// Generated by CoffeeScript 1.3.3
 var Delegator,
-  __slice = Array.prototype.slice,
-  __hasProp = Object.prototype.hasOwnProperty;
+  __slice = [].slice,
+  __hasProp = {}.hasOwnProperty;
 
 Delegator = (function() {
@@ -19,10 +20,10 @@
 
   Delegator.prototype.addEvents = function() {
-    var event, functionName, sel, selector, _i, _ref, _ref2, _results;
+    var event, functionName, sel, selector, _i, _ref, _ref1, _results;
     _ref = this.events;
     _results = [];
     for (sel in _ref) {
       functionName = _ref[sel];
-      _ref2 = sel.split(' '), selector = 2 <= _ref2.length ? __slice.call(_ref2, 0, _i = _ref2.length - 1) : (_i = 0, []), event = _ref2[_i++];
+      _ref1 = sel.split(' '), selector = 2 <= _ref1.length ? __slice.call(_ref1, 0, _i = _ref1.length - 1) : (_i = 0, []), event = _ref1[_i++];
       _results.push(this.addEvent(selector.join(' '), event, functionName));
     }
@@ -37,5 +38,7 @@
     };
     isBlankSelector = typeof bindTo === 'string' && bindTo.replace(/\s+/g, '') === '';
-    if (isBlankSelector) bindTo = this.element;
+    if (isBlankSelector) {
+      bindTo = this.element;
+    }
     if (typeof bindTo === 'string') {
       this.element.delegate(bindTo, event, closure);
Index: annotator_files/lib/console.js
===================================================================
--- annotator_files/lib/console.js	(revision 3)
+++ annotator_files/lib/console.js	(revision 4)
@@ -1,4 +1,5 @@
-var fn, functions, _i, _j, _len, _len2,
-  __slice = Array.prototype.slice;
+// Generated by CoffeeScript 1.3.3
+var fn, functions, _i, _j, _len, _len1,
+  __slice = [].slice;
 
 functions = ["log", "debug", "info", "warn", "exception", "assert", "dir", "dirxml", "trace", "group", "groupEnd", "groupCollapsed", "time", "timeEnd", "profile", "profileEnd", "count", "clear", "table", "error", "notifyFirebug", "firebug", "userObjects"];
@@ -10,5 +11,7 @@
     };
   }
-  if (!(console.groupCollapsed != null)) console.groupCollapsed = console.group;
+  if (!(console.groupCollapsed != null)) {
+    console.groupCollapsed = console.group;
+  }
   for (_i = 0, _len = functions.length; _i < _len; _i++) {
     fn = functions[_i];
@@ -21,5 +24,5 @@
 } else {
   this.console = {};
-  for (_j = 0, _len2 = functions.length; _j < _len2; _j++) {
+  for (_j = 0, _len1 = functions.length; _j < _len1; _j++) {
     fn = functions[_j];
     this.console[fn] = function() {};
Index: annotator_files/lib/editor.js
===================================================================
--- annotator_files/lib/editor.js	(revision 3)
+++ annotator_files/lib/editor.js	(revision 4)
@@ -1,5 +1,6 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Editor = (function(_super) {
@@ -26,9 +27,15 @@
   function Editor(options) {
     this.onCancelButtonMouseover = __bind(this.onCancelButtonMouseover, this);
+
     this.processKeypress = __bind(this.processKeypress, this);
+
     this.submit = __bind(this.submit, this);
+
     this.load = __bind(this.load, this);
+
     this.hide = __bind(this.hide, this);
-    this.show = __bind(this.show, this);    Editor.__super__.constructor.call(this, $(this.html)[0], options);
+
+    this.show = __bind(this.show, this);
+    Editor.__super__.constructor.call(this, $(this.html)[0], options);
     this.fields = [];
     this.annotation = {};
@@ -190,6 +197,10 @@
           textarea.height(height + (diff.top * directionY));
           textarea.width(width + (diff.left * directionX));
-          if (textarea.outerHeight() !== height) mousedown.top = event.pageY;
-          if (textarea.outerWidth() !== width) mousedown.left = event.pageX;
+          if (textarea.outerHeight() !== height) {
+            mousedown.top = event.pageY;
+          }
+          if (textarea.outerWidth() !== width) {
+            mousedown.left = event.pageX;
+          }
         } else if (mousedown.element === controls[0]) {
           editor.css({
Index: annotator_files/lib/extensions.js
===================================================================
--- annotator_files/lib/extensions.js	(revision 3)
+++ annotator_files/lib/extensions.js	(revision 4)
@@ -1,2 +1,3 @@
+// Generated by CoffeeScript 1.3.3
 var $, gettext, _gettext, _ref, _t;
 
@@ -92,5 +93,5 @@
     while (elem && elem.nodeType === 1 && elem !== relativeRoot) {
       idx = $(elem.parentNode).children(elem.tagName).index(elem) + 1;
-      idx = idx > 1 ? "[" + idx + "]" : "";
+      idx = "[" + idx + "]";
       path = "/" + elem.tagName.toLowerCase() + idx + path;
       elem = elem.parentNode;
@@ -106,5 +107,9 @@
 
 $.fn.escape = function(html) {
-  if (arguments.length) return this.html($.escape(html));
+  if (arguments.length) {
+    return this.html($.escape(html));
+  }
   return this.html();
 };
+
+$.fn.reverse = [].reverse;
Index: annotator_files/lib/notification.js
===================================================================
--- annotator_files/lib/notification.js	(revision 3)
+++ annotator_files/lib/notification.js	(revision 4)
@@ -1,6 +1,7 @@
+// Generated by CoffeeScript 1.3.3
 var Annotator,
   __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator = Annotator || {};
@@ -26,9 +27,13 @@
   function Notification(options) {
     this.hide = __bind(this.hide, this);
-    this.show = __bind(this.show, this);    Notification.__super__.constructor.call(this, $(this.options.html).appendTo(document.body)[0], options);
+
+    this.show = __bind(this.show, this);
+    Notification.__super__.constructor.call(this, $(this.options.html).appendTo(document.body)[0], options);
   }
 
   Notification.prototype.show = function(message, status) {
-    if (status == null) status = Annotator.Notification.INFO;
+    if (status == null) {
+      status = Annotator.Notification.INFO;
+    }
     $(this.element).addClass(this.options.classes.show).addClass(this.options.classes[status]).escape(message || "");
     setTimeout(this.hide, 5000);
Index: annotator_files/lib/plugin/annotateitpermissions.js
===================================================================
--- annotator_files/lib/plugin/annotateitpermissions.js	(revision 3)
+++ annotator_files/lib/plugin/annotateitpermissions.js	(revision 4)
@@ -1,10 +1,22 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; },
-  __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+  __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
 
 Annotator.Plugin.AnnotateItPermissions = (function(_super) {
 
   __extends(AnnotateItPermissions, _super);
+
+  function AnnotateItPermissions() {
+    this._setAuthFromToken = __bind(this._setAuthFromToken, this);
+
+    this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);
+
+    this.updatePermissionsField = __bind(this.updatePermissionsField, this);
+
+    this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this);
+    return AnnotateItPermissions.__super__.constructor.apply(this, arguments);
+  }
 
   AnnotateItPermissions.prototype.options = {
@@ -16,23 +28,26 @@
       consumer: 'group:__consumer__'
     },
+    userId: function(user) {
+      return user.userId;
+    },
     userString: function(user) {
-      return user;
+      return user.userId;
     },
-    userAuthorize: function(action, annotation, user, consumer) {
-      var action_field, permissions, _ref, _ref2, _ref3, _ref4;
+    userAuthorize: function(action, annotation, user) {
+      var action_field, permissions, _ref, _ref1, _ref2, _ref3;
       permissions = annotation.permissions || {};
       action_field = permissions[action] || [];
-      if (!(user && consumer)) {
-        return _ref = this.groups.world, __indexOf.call(action_field, _ref) >= 0;
-      } else {
-        if (_ref2 = this.groups.world, __indexOf.call(action_field, _ref2) >= 0) {
+      if (_ref = this.groups.world, __indexOf.call(action_field, _ref) >= 0) {
+        return true;
+      } else if ((user != null) && (user.userId != null) && (user.consumerKey != null)) {
+        if (user.userId === annotation.user && user.consumerKey === annotation.consumer) {
           return true;
-        } else if (user === annotation.user && consumer === annotation.consumer) {
+        } else if (_ref1 = this.groups.authenticated, __indexOf.call(action_field, _ref1) >= 0) {
           return true;
-        } else if (_ref3 = this.groups.authenticated, __indexOf.call(action_field, _ref3) >= 0) {
+        } else if (user.consumerKey === annotation.consumer && (_ref2 = this.groups.consumer, __indexOf.call(action_field, _ref2) >= 0)) {
           return true;
-        } else if (consumer === annotation.consumer && (_ref4 = this.groups.consumer, __indexOf.call(action_field, _ref4) >= 0)) {
+        } else if (user.consumerKey === annotation.consumer && (_ref3 = user.userId, __indexOf.call(action_field, _ref3) >= 0)) {
           return true;
-        } else if (consumer === annotation.consumer && __indexOf.call(action_field, user) >= 0) {
+        } else if (user.consumerKey === annotation.consumer && user.admin) {
           return true;
         } else {
@@ -41,6 +56,4 @@
       }
     },
-    user: '',
-    consumer: 'annotateit',
     permissions: {
       'read': ['group:__world__'],
@@ -51,32 +64,9 @@
   };
 
-  function AnnotateItPermissions(element, options) {
-    this._setAuthFromToken = __bind(this._setAuthFromToken, this);
-    this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);
-    this.updatePermissionsField = __bind(this.updatePermissionsField, this);
-    this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this);    AnnotateItPermissions.__super__.constructor.apply(this, arguments);
-    if (this.options.consumer) {
-      this.setConsumer(this.options.consumer);
-      delete this.options.consumer;
-    }
-  }
-
-  AnnotateItPermissions.prototype.setConsumer = function(consumer) {
-    return this.consumer = consumer;
-  };
-
-  AnnotateItPermissions.prototype.authorize = function(action, annotation, user, consumer) {
-    if (user === void 0) user = this.user;
-    if (consumer === void 0) consumer = this.consumer;
-    if (this.options.userAuthorize) {
-      return this.options.userAuthorize.call(this.options, action, annotation, user, consumer);
-    } else {
-      return true;
-    }
-  };
-
   AnnotateItPermissions.prototype.addFieldsToAnnotation = function(annotation) {
     AnnotateItPermissions.__super__.addFieldsToAnnotation.apply(this, arguments);
-    if (annotation && this.consumer) return annotation.consumer = this.consumer;
+    if (annotation && this.user) {
+      return annotation.consumer = this.user.consumerKey;
+    }
   };
 
@@ -85,6 +75,11 @@
     field = $(field).show();
     input = field.find('input').removeAttr('disabled');
-    if (!this.authorize('admin', annotation)) field.hide();
-    if (this.authorize(action, annotation || {}, '__nonexistentuser__')) {
+    if (!this.authorize('admin', annotation)) {
+      field.hide();
+    }
+    if (this.user && this.authorize(action, annotation || {}, {
+      userId: '__nonexistentuser__',
+      consumerKey: this.user.consumerKey
+    })) {
       return input.attr('checked', 'checked');
     } else {
@@ -95,5 +90,7 @@
   AnnotateItPermissions.prototype.updateAnnotationPermissions = function(type, field, annotation) {
     var dataKey;
-    if (!annotation.permissions) annotation.permissions = this.options.permissions;
+    if (!annotation.permissions) {
+      annotation.permissions = this.options.permissions;
+    }
     dataKey = type + '-permissions';
     if ($(field).find('input').is(':checked')) {
@@ -105,6 +102,5 @@
 
   AnnotateItPermissions.prototype._setAuthFromToken = function(token) {
-    AnnotateItPermissions.__super__._setAuthFromToken.apply(this, arguments);
-    return this.setConsumer(token.consumerKey);
+    return this.setUser(token);
   };
 
Index: annotator_files/lib/plugin/auth.js
===================================================================
--- annotator_files/lib/plugin/auth.js	(revision 3)
+++ annotator_files/lib/plugin/auth.js	(revision 4)
@@ -1,5 +1,6 @@
+// Generated by CoffeeScript 1.3.3
 var base64Decode, base64UrlDecode, createDateFromISO8601, parseToken,
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 createDateFromISO8601 = function(string) {
@@ -9,10 +10,22 @@
   offset = 0;
   date = new Date(d[1], 0, 1);
-  if (d[3]) date.setMonth(d[3] - 1);
-  if (d[5]) date.setDate(d[5]);
-  if (d[7]) date.setHours(d[7]);
-  if (d[8]) date.setMinutes(d[8]);
-  if (d[10]) date.setSeconds(d[10]);
-  if (d[12]) date.setMilliseconds(Number("0." + d[12]) * 1000);
+  if (d[3]) {
+    date.setMonth(d[3] - 1);
+  }
+  if (d[5]) {
+    date.setDate(d[5]);
+  }
+  if (d[7]) {
+    date.setHours(d[7]);
+  }
+  if (d[8]) {
+    date.setMinutes(d[8]);
+  }
+  if (d[10]) {
+    date.setSeconds(d[10]);
+  }
+  if (d[12]) {
+    date.setMilliseconds(Number("0." + d[12]) * 1000);
+  }
   if (d[14]) {
     offset = (Number(d[16]) * 60) + Number(d[17]);
@@ -37,5 +50,7 @@
     dec = "";
     tmp_arr = [];
-    if (!data) return data;
+    if (!data) {
+      return data;
+    }
     data += '';
     while (i < data.length) {
@@ -61,8 +76,8 @@
 
 base64UrlDecode = function(data) {
-  var i, m, _ref;
+  var i, m, _i, _ref;
   m = data.length % 4;
   if (m !== 0) {
-    for (i = 0, _ref = 4 - m; 0 <= _ref ? i < _ref : i > _ref; 0 <= _ref ? i++ : i--) {
+    for (i = _i = 0, _ref = 4 - m; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
       data += '=';
     }
@@ -176,10 +191,14 @@
 
   Auth.prototype.withToken = function(callback) {
-    if (!(callback != null)) return;
+    if (!(callback != null)) {
+      return;
+    }
     if (this.haveValidToken()) {
       return callback(this._unsafeToken);
     } else {
       this.waitingForToken.push(callback);
-      if (!this.requestInProgress) return this.requestToken();
+      if (!this.requestInProgress) {
+        return this.requestToken();
+      }
     }
   };
Index: annotator_files/lib/plugin/filter.js
===================================================================
--- annotator_files/lib/plugin/filter.js	(revision 3)
+++ annotator_files/lib/plugin/filter.js	(revision 4)
@@ -1,5 +1,6 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Plugin.Filter = (function(_super) {
@@ -35,9 +36,13 @@
     isFiltered: function(input, property) {
       var keyword, _i, _len, _ref;
-      if (!(input && property)) return false;
+      if (!(input && property)) {
+        return false;
+      }
       _ref = input.split(/\s*/);
       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
         keyword = _ref[_i];
-        if (property.indexOf(keyword) === -1) return false;
+        if (property.indexOf(keyword) === -1) {
+          return false;
+        }
       }
       return true;
@@ -47,10 +52,19 @@
   function Filter(element, options) {
     this._onPreviousClick = __bind(this._onPreviousClick, this);
+
     this._onNextClick = __bind(this._onNextClick, this);
+
     this._onFilterKeyup = __bind(this._onFilterKeyup, this);
+
     this._onFilterBlur = __bind(this._onFilterBlur, this);
+
     this._onFilterFocus = __bind(this._onFilterFocus, this);
-    this.updateHighlights = __bind(this.updateHighlights, this);    element = $(this.html.element).appendTo(this.options.appendTo);
+
+    this.updateHighlights = __bind(this.updateHighlights, this);
+
+    var _base;
+    element = $(this.html.element).appendTo((options != null ? options.appendTo : void 0) || this.options.appendTo);
     Filter.__super__.constructor.call(this, element, options);
+    (_base = this.options).filters || (_base.filters = []);
     this.filter = $(this.html.filter);
     this.filters = [];
@@ -106,5 +120,7 @@
       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
         f = _ref[_i];
-        if (f.property === filter.property) _results.push(f);
+        if (f.property === filter.property) {
+          _results.push(f);
+        }
       }
       return _results;
@@ -153,5 +169,5 @@
 
   Filter.prototype.filterHighlights = function() {
-    var activeFilters, annotation, annotations, filtered, highlights, index, uniques, _len, _ref;
+    var activeFilters, annotation, annotations, filtered, highlights, index, uniques, _i, _len, _ref;
     activeFilters = $.grep(this.filters, function(filter) {
       return !!filter.annotations.length;
@@ -174,5 +190,5 @@
     }
     highlights = this.highlights;
-    for (index = 0, _len = filtered.length; index < _len; index++) {
+    for (index = _i = 0, _len = filtered.length; _i < _len; index = ++_i) {
       annotation = filtered[index];
       highlights = highlights.not(annotation.highlights);
@@ -208,10 +224,14 @@
     var filter;
     filter = $(event.target).parent().data('filter');
-    if (filter) return this.updateFilter(filter);
+    if (filter) {
+      return this.updateFilter(filter);
+    }
   };
 
   Filter.prototype._findNextHighlight = function(previous) {
     var active, annotation, current, index, next, offset, operator, resetOffset;
-    if (!this.highlights.length) return this;
+    if (!this.highlights.length) {
+      return this;
+    }
     offset = previous ? 0 : -1;
     resetOffset = previous ? -1 : 0;
@@ -219,9 +239,13 @@
     active = this.highlights.not('.' + this.classes.hl.hide);
     current = active.filter('.' + this.classes.hl.active);
-    if (!current.length) current = active.eq(offset);
+    if (!current.length) {
+      current = active.eq(offset);
+    }
     annotation = current.data('annotation');
     index = active.index(current[0]);
     next = active.filter(":" + operator + "(" + index + ")").not(annotation.highlights).eq(resetOffset);
-    if (!next.length) next = active.eq(resetOffset);
+    if (!next.length) {
+      next = active.eq(resetOffset);
+    }
     return this._scrollToHighlight(next.data('annotation').highlights);
   };
Index: annotator_files/lib/plugin/kitchensink.js
===================================================================
--- annotator_files/lib/plugin/kitchensink.js	(revision 3)
+++ annotator_files/lib/plugin/kitchensink.js	(revision 4)
@@ -1,12 +1,19 @@
-var __hasProp = Object.prototype.hasOwnProperty,
-  __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+// Generated by CoffeeScript 1.3.3
+var __hasProp = {}.hasOwnProperty,
+  __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
 
 Annotator.prototype.setupPlugins = function(config, options) {
   var name, opts, pluginConfig, plugins, uri, win, _i, _len, _results;
-  if (config == null) config = {};
-  if (options == null) options = {};
+  if (config == null) {
+    config = {};
+  }
+  if (options == null) {
+    options = {};
+  }
   win = util.getGlobal();
-  plugins = ['Unsupported', 'Auth', 'Tags', 'Filter', 'Store', 'Permissions'];
-  if (win.Showdown) plugins.push('Markdown');
+  plugins = ['Unsupported', 'Auth', 'Tags', 'Filter', 'Store', 'AnnotateItPermissions'];
+  if (win.Showdown) {
+    plugins.push('Markdown');
+  }
   uri = win.location.href.split(/#|\?/).shift() || '';
   pluginConfig = {
@@ -39,5 +46,7 @@
     if (!__hasProp.call(options, name)) continue;
     opts = options[name];
-    if (__indexOf.call(plugins, name) < 0) plugins.push(name);
+    if (__indexOf.call(plugins, name) < 0) {
+      plugins.push(name);
+    }
   }
   $.extend(true, pluginConfig, options);
Index: annotator_files/lib/plugin/markdown.js
===================================================================
--- annotator_files/lib/plugin/markdown.js	(revision 3)
+++ annotator_files/lib/plugin/markdown.js	(revision 4)
@@ -1,5 +1,6 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Plugin.Markdown = (function(_super) {
@@ -12,5 +13,6 @@
 
   function Markdown(element, options) {
-    this.updateTextField = __bind(this.updateTextField, this);    if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) {
+    this.updateTextField = __bind(this.updateTextField, this);
+    if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) {
       Markdown.__super__.constructor.apply(this, arguments);
       this.converter = new Showdown.converter();
Index: annotator_files/lib/plugin/permissions.js
===================================================================
--- annotator_files/lib/plugin/permissions.js	(revision 3)
+++ annotator_files/lib/plugin/permissions.js	(revision 4)
@@ -1,5 +1,6 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Plugin.Permissions = (function(_super) {
@@ -24,8 +25,12 @@
       if (annotation.permissions) {
         tokens = annotation.permissions[action] || [];
-        if (tokens.length === 0) return true;
+        if (tokens.length === 0) {
+          return true;
+        }
         for (_i = 0, _len = tokens.length; _i < _len; _i++) {
           token = tokens[_i];
-          if (this.userId(user) === token) return true;
+          if (this.userId(user) === token) {
+            return true;
+          }
         }
         return false;
@@ -46,8 +51,13 @@
   function Permissions(element, options) {
     this._setAuthFromToken = __bind(this._setAuthFromToken, this);
+
     this.updateViewer = __bind(this.updateViewer, this);
+
     this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);
+
     this.updatePermissionsField = __bind(this.updatePermissionsField, this);
-    this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this);    Permissions.__super__.constructor.apply(this, arguments);
+
+    this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this);
+    Permissions.__super__.constructor.apply(this, arguments);
     if (this.options.user) {
       this.setUser(this.options.user);
@@ -59,5 +69,7 @@
     var createCallback, self,
       _this = this;
-    if (!Annotator.supported()) return;
+    if (!Annotator.supported()) {
+      return;
+    }
     self = this;
     createCallback = function(method, type) {
@@ -95,9 +107,13 @@
           var keyword, _i, _len, _ref;
           user = _this.options.userString(user);
-          if (!(input && user)) return false;
+          if (!(input && user)) {
+            return false;
+          }
           _ref = input.split(/\s*/);
           for (_i = 0, _len = _ref.length; _i < _len; _i++) {
             keyword = _ref[_i];
-            if (user.indexOf(keyword) === -1) return false;
+            if (user.indexOf(keyword) === -1) {
+              return false;
+            }
           }
           return true;
@@ -114,10 +130,14 @@
     if (annotation) {
       annotation.permissions = this.options.permissions;
-      if (this.user) return annotation.user = this.user;
+      if (this.user) {
+        return annotation.user = this.user;
+      }
     }
   };
 
   Permissions.prototype.authorize = function(action, annotation, user) {
-    if (user === void 0) user = this.user;
+    if (user === void 0) {
+      user = this.user;
+    }
     if (this.options.userAuthorize) {
       return this.options.userAuthorize.call(this.options, action, annotation, user);
@@ -131,5 +151,7 @@
     field = $(field).show();
     input = field.find('input').removeAttr('disabled');
-    if (!this.authorize('admin', annotation)) field.hide();
+    if (!this.authorize('admin', annotation)) {
+      field.hide();
+    }
     if (this.authorize(action, annotation || {}, null)) {
       return input.attr('checked', 'checked');
@@ -141,5 +163,7 @@
   Permissions.prototype.updateAnnotationPermissions = function(type, field, annotation) {
     var dataKey;
-    if (!annotation.permissions) annotation.permissions = this.options.permissions;
+    if (!annotation.permissions) {
+      annotation.permissions = this.options.permissions;
+    }
     dataKey = type + '-permissions';
     if ($(field).find('input').is(':checked')) {
@@ -160,6 +184,10 @@
       field.remove();
     }
-    if (!this.authorize('update', annotation)) controls.hideEdit();
-    if (!this.authorize('delete', annotation)) return controls.hideDelete();
+    if (!this.authorize('update', annotation)) {
+      controls.hideEdit();
+    }
+    if (!this.authorize('delete', annotation)) {
+      return controls.hideDelete();
+    }
   };
 
Index: annotator_files/lib/plugin/store.js
===================================================================
--- annotator_files/lib/plugin/store.js	(revision 3)
+++ annotator_files/lib/plugin/store.js	(revision 4)
@@ -1,6 +1,7 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; },
-  __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+  __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
 
 Annotator.Plugin.Store = (function(_super) {
@@ -30,12 +31,18 @@
   function Store(element, options) {
     this._onError = __bind(this._onError, this);
+
     this._onLoadAnnotationsFromSearch = __bind(this._onLoadAnnotationsFromSearch, this);
+
     this._onLoadAnnotations = __bind(this._onLoadAnnotations, this);
-    this._getAnnotations = __bind(this._getAnnotations, this);    Store.__super__.constructor.apply(this, arguments);
+
+    this._getAnnotations = __bind(this._getAnnotations, this);
+    Store.__super__.constructor.apply(this, arguments);
     this.annotations = [];
   }
 
   Store.prototype.pluginInit = function() {
-    if (!Annotator.supported()) return;
+    if (!Annotator.supported()) {
+      return;
+    }
     if (this.annotator.plugins.Auth) {
       return this.annotator.plugins.Auth.withToken(this._getAnnotations);
@@ -108,5 +115,7 @@
 
   Store.prototype._onLoadAnnotations = function(data) {
-    if (data == null) data = [];
+    if (data == null) {
+      data = [];
+    }
     this.annotations = data;
     return this.annotator.loadAnnotations(data.slice());
@@ -118,5 +127,7 @@
 
   Store.prototype._onLoadAnnotationsFromSearch = function(data) {
-    if (data == null) data = {};
+    if (data == null) {
+      data = {};
+    }
     return this._onLoadAnnotations(data.rows || []);
   };
@@ -193,5 +204,7 @@
     $.extend(annotation, this.options.annotationData);
     data = JSON.stringify(annotation);
-    if (highlights) annotation.highlights = highlights;
+    if (highlights) {
+      annotation.highlights = highlights;
+    }
     return data;
   };
Index: annotator_files/lib/plugin/tags.js
===================================================================
--- annotator_files/lib/plugin/tags.js	(revision 3)
+++ annotator_files/lib/plugin/tags.js	(revision 4)
@@ -1,5 +1,6 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Plugin.Tags = (function(_super) {
@@ -9,6 +10,7 @@
   function Tags() {
     this.setAnnotationTags = __bind(this.setAnnotationTags, this);
+
     this.updateField = __bind(this.updateField, this);
-    Tags.__super__.constructor.apply(this, arguments);
+    return Tags.__super__.constructor.apply(this, arguments);
   }
 
@@ -18,5 +20,7 @@
       string = $.trim(string);
       tags = [];
-      if (string) tags = string.split(/\s+/);
+      if (string) {
+        tags = string.split(/\s+/);
+      }
       return tags;
     },
@@ -31,5 +35,7 @@
 
   Tags.prototype.pluginInit = function() {
-    if (!Annotator.supported()) return;
+    if (!Annotator.supported()) {
+      return;
+    }
     this.field = this.annotator.editor.addField({
       label: Annotator._t('Add some tags here') + '\u2026',
@@ -61,5 +67,7 @@
     var value;
     value = '';
-    if (annotation.tags) value = this.stringifyTags(annotation.tags);
+    if (annotation.tags) {
+      value = this.stringifyTags(annotation.tags);
+    }
     return this.input.val(value);
   };
@@ -88,6 +96,8 @@
 
 Annotator.Plugin.Tags.filterCallback = function(input, tags) {
-  var keyword, keywords, matches, tag, _i, _j, _len, _len2;
-  if (tags == null) tags = [];
+  var keyword, keywords, matches, tag, _i, _j, _len, _len1;
+  if (tags == null) {
+    tags = [];
+  }
   matches = 0;
   keywords = [];
@@ -97,7 +107,9 @@
       keyword = keywords[_i];
       if (tags.length) {
-        for (_j = 0, _len2 = tags.length; _j < _len2; _j++) {
+        for (_j = 0, _len1 = tags.length; _j < _len1; _j++) {
           tag = tags[_j];
-          if (tag.indexOf(keyword) !== -1) matches += 1;
+          if (tag.indexOf(keyword) !== -1) {
+            matches += 1;
+          }
         }
       }
Index: annotator_files/lib/plugin/unsupported.js
===================================================================
--- annotator_files/lib/plugin/unsupported.js	(revision 3)
+++ annotator_files/lib/plugin/unsupported.js	(revision 4)
@@ -1,4 +1,5 @@
-var __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+// Generated by CoffeeScript 1.3.3
+var __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Plugin.Unsupported = (function(_super) {
@@ -7,5 +8,5 @@
 
   function Unsupported() {
-    Unsupported.__super__.constructor.apply(this, arguments);
+    return Unsupported.__super__.constructor.apply(this, arguments);
   }
 
Index: annotator_files/lib/range.js
===================================================================
--- annotator_files/lib/range.js	(revision 3)
+++ annotator_files/lib/range.js	(revision 4)
@@ -1,3 +1,6 @@
-var Range;
+// Generated by CoffeeScript 1.3.3
+var Range,
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Range = {};
@@ -16,4 +19,64 @@
 };
 
+Range.nodeFromXPath = function(xpath, root) {
+  var customResolver, evaluateXPath, namespace, node, segment;
+  if (root == null) {
+    root = document;
+  }
+  evaluateXPath = function(xp, nsResolver) {
+    if (nsResolver == null) {
+      nsResolver = null;
+    }
+    return document.evaluate('.' + xp, root, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
+  };
+  if (!$.isXMLDoc(document.documentElement)) {
+    return evaluateXPath(xpath);
+  } else {
+    customResolver = document.createNSResolver(document.ownerDocument === null ? document.documentElement : document.ownerDocument.documentElement);
+    node = evaluateXPath(xpath, customResolver);
+    if (!node) {
+      xpath = ((function() {
+        var _i, _len, _ref, _results;
+        _ref = xpath.split('/');
+        _results = [];
+        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+          segment = _ref[_i];
+          if (segment && segment.indexOf(':') === -1) {
+            _results.push(segment.replace(/^([a-z]+)/, 'xhtml:$1'));
+          } else {
+            _results.push(segment);
+          }
+        }
+        return _results;
+      })()).join('/');
+      namespace = document.lookupNamespaceURI(null);
+      customResolver = function(ns) {
+        if (ns === 'xhtml') {
+          return namespace;
+        } else {
+          return document.documentElement.getAttribute('xmlns:' + ns);
+        }
+      };
+      node = evaluateXPath(xpath, customResolver);
+    }
+    return node;
+  }
+};
+
+Range.RangeError = (function(_super) {
+
+  __extends(RangeError, _super);
+
+  function RangeError(type, message, parent) {
+    this.type = type;
+    this.message = message;
+    this.parent = parent != null ? parent : null;
+    RangeError.__super__.constructor.call(this, this.message);
+  }
+
+  return RangeError;
+
+})(Error);
+
 Range.BrowserRange = (function() {
 
@@ -41,5 +104,7 @@
       node = this[p + 'Container'];
       offset = this[p + 'Offset'];
-      if (!((node != null) && (offset != null))) return false;
+      if (!((node != null) && (offset != null))) {
+        return false;
+      }
       if (node.nodeType === 1) {
         it = node.childNodes[offset];
@@ -64,5 +129,7 @@
       nr.end = nr.start;
     } else {
-      if (r.endOffset < r.end.nodeValue.length) r.end.splitText(r.endOffset);
+      if (r.endOffset < r.end.nodeValue.length) {
+        r.end.splitText(r.endOffset);
+      }
       nr.end = r.end;
     }
@@ -99,5 +166,7 @@
       return node.parentNode === bounds || $.contains(bounds, node.parentNode);
     });
-    if (!nodes.length) return null;
+    if (!nodes.length) {
+      return null;
+    }
     this.start = nodes[0];
     this.end = nodes[nodes.length - 1];
@@ -189,71 +258,22 @@
   }
 
-  SerializedRange.prototype._nodeFromXPath = function(xpath) {
-    var customResolver, evaluateXPath, namespace, node, segment;
-    evaluateXPath = function(xp, nsResolver) {
-      if (nsResolver == null) nsResolver = null;
-      return document.evaluate(xp, document, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
-    };
-    if (!$.isXMLDoc(document.documentElement)) {
-      return evaluateXPath(xpath);
-    } else {
-      customResolver = document.createNSResolver(document.ownerDocument === null ? document.documentElement : document.ownerDocument.documentElement);
-      node = evaluateXPath(xpath, customResolver);
+  SerializedRange.prototype.normalize = function(root) {
+    var contains, length, node, p, range, tn, _i, _j, _len, _len1, _ref, _ref1;
+    range = {};
+    _ref = ['start', 'end'];
+    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+      p = _ref[_i];
+      try {
+        node = Range.nodeFromXPath(this[p], root);
+      } catch (e) {
+        throw new Range.RangeError(p, ("Error while finding " + p + " node: " + this[p] + ": ") + e, e);
+      }
       if (!node) {
-        xpath = ((function() {
-          var _i, _len, _ref, _results;
-          _ref = xpath.split('/');
-          _results = [];
-          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-            segment = _ref[_i];
-            if (segment && segment.indexOf(':') === -1) {
-              _results.push(segment.replace(/^([a-z]+)/, 'xhtml:$1'));
-            } else {
-              _results.push(segment);
-            }
-          }
-          return _results;
-        })()).join('/');
-        namespace = document.lookupNamespaceURI(null);
-        customResolver = function(ns) {
-          if (ns === 'xhtml') {
-            return namespace;
-          } else {
-            return document.documentElement.getAttribute('xmlns:' + ns);
-          }
-        };
-        node = evaluateXPath(xpath, customResolver);
-      }
-      return node;
-    }
-  };
-
-  SerializedRange.prototype.normalize = function(root) {
-    var cacXPath, common, endAncestry, i, length, p, parentXPath, range, startAncestry, tn, _i, _j, _len, _len2, _ref, _ref2, _ref3;
-    parentXPath = $(root).xpath()[0];
-    startAncestry = this.start.split("/");
-    endAncestry = this.end.split("/");
-    common = [];
-    range = {};
-    for (i = 0, _ref = startAncestry.length; 0 <= _ref ? i < _ref : i > _ref; 0 <= _ref ? i++ : i--) {
-      if (startAncestry[i] === endAncestry[i]) {
-        common.push(startAncestry[i]);
-      } else {
-        break;
-      }
-    }
-    cacXPath = parentXPath + common.join("/");
-    range.commonAncestorContainer = this._nodeFromXPath(cacXPath);
-    if (!range.commonAncestorContainer) {
-      console.error(_t("Error deserializing range: can't find XPath '") + cacXPath + _t("'. Is this the right document?"));
-      return null;
-    }
-    _ref2 = ['start', 'end'];
-    for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
-      p = _ref2[_i];
+        throw new Range.RangeError(p, "Couldn't find " + p + " node: " + this[p]);
+      }
       length = 0;
-      _ref3 = $(this._nodeFromXPath(parentXPath + this[p])).textNodes();
-      for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
-        tn = _ref3[_j];
+      _ref1 = $(node).textNodes();
+      for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+        tn = _ref1[_j];
         if (length + tn.nodeValue.length >= this[p + 'Offset']) {
           range[p + 'Container'] = tn;
@@ -264,5 +284,19 @@
         }
       }
-    }
+      if (!(range[p + 'Offset'] != null)) {
+        throw new Range.RangeError("" + p + "offset", "Couldn't find offset " + this[p + 'Offset'] + " in element " + this[p]);
+      }
+    }
+    contains = !(document.compareDocumentPosition != null) ? function(a, b) {
+      return a.contains(b);
+    } : function(a, b) {
+      return a.compareDocumentPosition(b) & 16;
+    };
+    $(range.startContainer).parents().reverse().each(function() {
+      if (contains(this, range.endContainer)) {
+        range.commonAncestorContainer = this;
+        return false;
+      }
+    });
     return new Range.BrowserRange(range).normalize(root);
   };
Index: annotator_files/lib/viewer.js
===================================================================
--- annotator_files/lib/viewer.js	(revision 3)
+++ annotator_files/lib/viewer.js	(revision 4)
@@ -1,6 +1,7 @@
+// Generated by CoffeeScript 1.3.3
 var LinkParser,
   __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+  __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Viewer = (function(_super) {
@@ -29,8 +30,13 @@
   function Viewer(options) {
     this.onDeleteClick = __bind(this.onDeleteClick, this);
+
     this.onEditClick = __bind(this.onEditClick, this);
+
     this.load = __bind(this.load, this);
+
     this.hide = __bind(this.hide, this);
-    this.show = __bind(this.show, this);    Viewer.__super__.constructor.call(this, $(this.html.element)[0], options);
+
+    this.show = __bind(this.show, this);
+    Viewer.__super__.constructor.call(this, $(this.html.element)[0], options);
     this.item = $(this.html.item)[0];
     this.fields = [];
@@ -61,5 +67,5 @@
 
   Viewer.prototype.load = function(annotations) {
-    var annotation, controller, controls, del, edit, element, field, item, link, links, list, _i, _j, _len, _len2, _ref, _ref2;
+    var annotation, controller, controls, del, edit, element, field, item, link, links, list, _i, _j, _len, _len1, _ref, _ref1;
     this.annotations = annotations || [];
     list = this.element.find('ul:first').empty();
@@ -99,7 +105,7 @@
         };
       }
-      _ref2 = this.fields;
-      for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
-        field = _ref2[_j];
+      _ref1 = this.fields;
+      for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+        field = _ref1[_j];
         element = $(field.element).clone().appendTo(item)[0];
         field.load(element, annotation, controller);
@@ -147,5 +153,7 @@
   LinkParser.prototype.get = function(rel, cond) {
     var d, k, keys, match, v, _i, _len, _ref, _results;
-    if (cond == null) cond = {};
+    if (cond == null) {
+      cond = {};
+    }
     cond = $.extend({}, cond, {
       rel: rel
Index: annotator_files/lib/widget.js
===================================================================
--- annotator_files/lib/widget.js	(revision 3)
+++ annotator_files/lib/widget.js	(revision 4)
@@ -1,4 +1,5 @@
-var __hasProp = Object.prototype.hasOwnProperty,
-  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
+// Generated by CoffeeScript 1.3.3
+var __hasProp = {}.hasOwnProperty,
+  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
 
 Annotator.Widget = (function(_super) {
@@ -33,6 +34,10 @@
       right: offset.left + widget.width()
     };
-    if ((current.top - viewport.top) < 0) this.invertY();
-    if ((current.right - viewport.right) > 0) this.invertX();
+    if ((current.top - viewport.top) < 0) {
+      this.invertY();
+    }
+    if ((current.right - viewport.right) > 0) {
+      this.invertX();
+    }
     return this;
   };
