Index: src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java
===================================================================
--- src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java	(revision 67)
+++ src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java	(revision 68)
@@ -63,5 +63,5 @@
         nodeIndexes = new ArrayList<Index<Node>>(5);
         // List.set(enum.ordinal(), val) seems not to work.
-        try ( Transaction tx = graphDb.beginTx() ) {
+        try (Transaction tx = graphDb.beginTx()) {
             nodeIndexes.add(NodeTypes.ANNOTATION.ordinal(), graphDb.index().forNodes("annotations"));
             nodeIndexes.add(NodeTypes.PERSON.ordinal(), graphDb.index().forNodes("persons"));
@@ -119,5 +119,6 @@
      */
     public Node getNodeFromIndex(String key, String value, NodeTypes type) {
-        if (key == null || value == null) return null;
+        if (key == null || value == null)
+            return null;
         Node node = null;
         try (Transaction tx = graphDb.beginTx()) {
@@ -151,5 +152,5 @@
                 actors.add((T) actor);
             }
-            tx.success();
+            tx.success();            
         }
         return actors;
@@ -313,16 +314,18 @@
     public boolean isPersonInGroup(Person person, Group group) {
         Node pn = getPersonNodeByUri(person.getUriString());
-        if (pn == null) return false;
+        if (pn == null)
+            return false;
         // optimized version of getGroupsForPersonNode
         try (Transaction tx = graphDb.beginTx()) {
-        Iterable<Relationship> rels = pn.getRelationships(RelationTypes.MEMBER_OF);
-        for (Relationship rel : rels) {
-            Node gn = rel.getEndNode();
-            if (gn.getProperty("uri", "").equals(group.getUriString()) || gn.getProperty("id", "").equals(group.getId())) {
-                tx.success();
-                return true;
-            }
-        }
-        tx.success();
+            Iterable<Relationship> rels = pn.getRelationships(RelationTypes.MEMBER_OF);
+            for (Relationship rel : rels) {
+                Node gn = rel.getEndNode();
+                if (gn.getProperty("uri", "").equals(group.getUriString()) 
+                        || gn.getProperty("id", "").equals(group.getId())) {
+                    tx.success();
+                    return true;
+                }
+            }
+            tx.success();
         }
         return false;
@@ -382,10 +385,7 @@
             Node mn = rel.getStartNode();
             if (mn.equals(pn)) {
-                Transaction tx = graphDb.beginTx();
-                try {
+                try (Transaction tx = graphDb.beginTx()) {
                     rel.delete();
                     tx.success();
-                } finally {
-                    tx.finish();
                 }
                 // there should be only one
@@ -416,6 +416,5 @@
     public Actor storeActor(Actor actor) {
         Node actorNode = getOrCreateActorNode(actor);
-        Transaction tx = graphDb.beginTx();
-        try {
+        try (Transaction tx = graphDb.beginTx()) {
             // id
             String id = actor.getId();
@@ -434,6 +433,4 @@
             }
             tx.success();
-        } finally {
-            tx.finish();
         }
         Actor storedActor = createActorFromNode(actorNode);
@@ -457,6 +454,5 @@
         if (actorNode != null) {
             // delete relations
-            Transaction tx = graphDb.beginTx();
-            try {
+            try (Transaction tx = graphDb.beginTx()) {
                 for (Relationship rel : actorNode.getRelationships()) {
                     rel.delete();
@@ -469,6 +465,4 @@
                 }
                 tx.success();
-            } finally {
-                tx.finish();
             }
         }
@@ -483,8 +477,8 @@
     public Annotation getAnnotationById(String id) {
         Annotation annot = null;
-        try ( Transaction tx = graphDb.beginTx() ) {
-        Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle();
-        annot = createAnnotationFromNode(annotNode);
-        tx.success();
+        try (Transaction tx = graphDb.beginTx()) {
+            Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle();
+            annot = createAnnotationFromNode(annotNode);
+            tx.success();
         }
         return annot;
@@ -499,84 +493,84 @@
     public Annotation createAnnotationFromNode(Node annotNode) {
         Annotation annot = new Annotation();
-        try ( Transaction tx = graphDb.beginTx() ) {        
-        annot.setUri((String) annotNode.getProperty("id", null));
-        annot.setBodyText((String) annotNode.getProperty("bodyText", null));
-        annot.setBodyUri((String) annotNode.getProperty("bodyUri", null));
-        /*
-         * get annotation target and resource from relation
-         */
-        for (Relationship rel : annotNode.getRelationships(RelationTypes.ANNOTATES)) {
-            Node target = rel.getEndNode();
-            String type = (String) target.getProperty("TYPE");
-            if (type.equals("TARGET")) {
-                annot.setTarget(new Target((String) target.getProperty("uri", null)));
-            } else if (type.equals("RESOURCE")) {
-                annot.setResource(new Resource((String) target.getProperty("uri", null)));
-            }
-        }
-        if (annot.getTarget() == null) {
-            logger.error("annotation " + annotNode + " has no target node!");
-        }
-        // get fragment from attribute
-        annot.setTargetFragment((String) annotNode.getProperty("targetFragment", null));
-        String ft = (String) annotNode.getProperty("fragmentType", null);
-        if (ft != null) {
-            annot.setFragmentType(FragmentTypes.valueOf(ft));
-        }
-        /*
-         * get creator from relation
-         */
-        Relationship creatorRel = getRelation(annotNode, RelationTypes.CREATED, null);
-        if (creatorRel != null) {
-            Node creatorNode = creatorRel.getStartNode();
-            Actor creator = createActorFromNode(creatorNode);
-            annot.setCreator(creator);
-        } else {
-            logger.error("annotation " + annotNode + " has no creator node!");
-        }
-        /*
-         * get creation date
-         */
-        annot.setCreated((String) annotNode.getProperty("created", null));
-        /*
-         * get permissions
-         */
-        Relationship adminRel = getRelation(annotNode, RelationTypes.PERMITS_ADMIN, null);
-        if (adminRel != null) {
-            Node adminNode = adminRel.getEndNode();
-            Actor admin = createActorFromNode(adminNode);
-            annot.setAdminPermission(admin);
-        }
-        Relationship deleteRel = getRelation(annotNode, RelationTypes.PERMITS_DELETE, null);
-        if (deleteRel != null) {
-            Node deleteNode = deleteRel.getEndNode();
-            Actor delete = createActorFromNode(deleteNode);
-            annot.setDeletePermission(delete);
-        }
-        Relationship updateRel = getRelation(annotNode, RelationTypes.PERMITS_UPDATE, null);
-        if (updateRel != null) {
-            Node updateNode = updateRel.getEndNode();
-            Actor update = createActorFromNode(updateNode);
-            annot.setUpdatePermission(update);
-        }
-        Relationship readRel = getRelation(annotNode, RelationTypes.PERMITS_READ, null);
-        if (readRel != null) {
-            Node readNode = readRel.getEndNode();
-            Actor read = createActorFromNode(readNode);
-            annot.setReadPermission(read);
-        }
-        /*
-         * get tags
-         */
-        Set<String> tags = new HashSet<String>();
-        for (Relationship rel : annotNode.getRelationships(RelationTypes.HAS_TAG)) {
-            String tag = (String) rel.getEndNode().getProperty("name", null);
-            if (tag != null) {
-                tags.add(tag);
-            }
-        }
-        annot.setTags(tags);
-        
-        tx.success();
+        try (Transaction tx = graphDb.beginTx()) {
+            annot.setUri((String) annotNode.getProperty("id", null));
+            annot.setBodyText((String) annotNode.getProperty("bodyText", null));
+            annot.setBodyUri((String) annotNode.getProperty("bodyUri", null));
+            /*
+             * get annotation target and resource from relation
+             */
+            for (Relationship rel : annotNode.getRelationships(RelationTypes.ANNOTATES)) {
+                Node target = rel.getEndNode();
+                String type = (String) target.getProperty("TYPE");
+                if (type.equals("TARGET")) {
+                    annot.setTarget(new Target((String) target.getProperty("uri", null)));
+                } else if (type.equals("RESOURCE")) {
+                    annot.setResource(new Resource((String) target.getProperty("uri", null)));
+                }
+            }
+            if (annot.getTarget() == null) {
+                logger.warn("annotation " + annotNode + " has no target node!");
+            }
+            // get fragment from attribute
+            annot.setTargetFragment((String) annotNode.getProperty("targetFragment", null));
+            String ft = (String) annotNode.getProperty("fragmentType", null);
+            if (ft != null) {
+                annot.setFragmentType(FragmentTypes.valueOf(ft));
+            }
+            /*
+             * get creator from relation
+             */
+            Relationship creatorRel = getRelation(annotNode, RelationTypes.CREATED, null);
+            if (creatorRel != null) {
+                Node creatorNode = creatorRel.getStartNode();
+                Actor creator = createActorFromNode(creatorNode);
+                annot.setCreator(creator);
+            } else {
+                logger.warn("annotation " + annotNode + " has no creator node!");
+            }
+            /*
+             * get creation date
+             */
+            annot.setCreated((String) annotNode.getProperty("created", null));
+            /*
+             * get permissions
+             */
+            Relationship adminRel = getRelation(annotNode, RelationTypes.PERMITS_ADMIN, null);
+            if (adminRel != null) {
+                Node adminNode = adminRel.getEndNode();
+                Actor admin = createActorFromNode(adminNode);
+                annot.setAdminPermission(admin);
+            }
+            Relationship deleteRel = getRelation(annotNode, RelationTypes.PERMITS_DELETE, null);
+            if (deleteRel != null) {
+                Node deleteNode = deleteRel.getEndNode();
+                Actor delete = createActorFromNode(deleteNode);
+                annot.setDeletePermission(delete);
+            }
+            Relationship updateRel = getRelation(annotNode, RelationTypes.PERMITS_UPDATE, null);
+            if (updateRel != null) {
+                Node updateNode = updateRel.getEndNode();
+                Actor update = createActorFromNode(updateNode);
+                annot.setUpdatePermission(update);
+            }
+            Relationship readRel = getRelation(annotNode, RelationTypes.PERMITS_READ, null);
+            if (readRel != null) {
+                Node readNode = readRel.getEndNode();
+                Actor read = createActorFromNode(readNode);
+                annot.setReadPermission(read);
+            }
+            /*
+             * get tags
+             */
+            Set<String> tags = new HashSet<String>();
+            for (Relationship rel : annotNode.getRelationships(RelationTypes.HAS_TAG)) {
+                String tag = (String) rel.getEndNode().getProperty("name", null);
+                if (tag != null) {
+                    tags.add(tag);
+                }
+            }
+            annot.setTags(tags);
+
+            tx.success();
         }
         return annot;
@@ -590,13 +584,17 @@
      */
     protected Actor createActorFromNode(Node actorNode) {
-        if (actorNode == null) return null;
-        String id = (String) actorNode.getProperty("id", null);
-        String uri = (String) actorNode.getProperty("uri", null);
-        String name = (String) actorNode.getProperty("name", null);
-        String type = (String) actorNode.getProperty("TYPE", null);
-        if (type != null && type.equals("PERSON")) {
-            return new Person(id, uri, name);
-        } else if (type != null && type.equals("GROUP")) {
-            return new Group(id, uri, name);
+        if (actorNode == null)
+            return null;
+        try (Transaction tx = graphDb.beginTx()) {
+            String id = (String) actorNode.getProperty("id", null);
+            String uri = (String) actorNode.getProperty("uri", null);
+            String name = (String) actorNode.getProperty("name", null);
+            String type = (String) actorNode.getProperty("TYPE", null);
+            tx.success();
+            if (type != null && type.equals("PERSON")) {
+                return new Person(id, uri, name);
+            } else if (type != null && type.equals("GROUP")) {
+                return new Group(id, uri, name);
+            }
         }
         return null;
@@ -604,9 +602,15 @@
 
     public Tag createTagFromNode(Node tagNode) {
-        if (tagNode == null) return null;
-        String name = (String) tagNode.getProperty("name", null);
-        String uri = (String) tagNode.getProperty("uri", null);
-        String id = (String) tagNode.getProperty("id", null);
-
+        if (tagNode == null)
+            return null;
+        String id;
+        String uri;
+        String name;
+        try (Transaction tx = graphDb.beginTx()) {
+            name = (String) tagNode.getProperty("name", null);
+            uri = (String) tagNode.getProperty("uri", null);
+            id = (String) tagNode.getProperty("id", null);
+            tx.success();
+        }
         return new Tag(id, uri, name);
 
@@ -630,11 +634,15 @@
 
     protected Uri createUriFromNode(Node uriNode) {
-        if (uriNode == null) return null;
-        String uri = (String) uriNode.getProperty("uri", null);
-        String type = (String) uriNode.getProperty("TYPE", null);
-        if (type != null && type.equals("TARGET")) {
-            return new Target(uri);
-        } else if (type != null && type.equals("RESOURCE")) {
-            return new Resource(uri);
+        if (uriNode == null)
+            return null;
+        try (Transaction tx = graphDb.beginTx()) {
+            String uri = (String) uriNode.getProperty("uri", null);
+            String type = (String) uriNode.getProperty("TYPE", null);
+            tx.success();
+            if (type != null && type.equals("TARGET")) {
+                return new Target(uri);
+            } else if (type != null && type.equals("RESOURCE")) {
+                return new Resource(uri);
+            }
         }
         return null;
@@ -650,6 +658,5 @@
     public Annotation storeAnnotation(Annotation annot) {
         Node annotNode = null;
-        Transaction tx = graphDb.beginTx();
-        try {
+        try (Transaction tx = graphDb.beginTx()) {
             /*
              * create or get the annotation
@@ -672,5 +679,5 @@
                 annotNode.setProperty("bodyUri", bodyUri);
             }
-
+                
             /*
              * the annotation target
@@ -774,6 +781,4 @@
             }
             tx.success();
-        } finally {
-            tx.finish();
         }
 
@@ -789,9 +794,8 @@
      */
     public void deleteAnnotationById(String id) {
-        Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle();
-        if (annotNode != null) {
-            // delete related objects
-            Transaction tx = graphDb.beginTx();
-            try {
+        try (Transaction tx = graphDb.beginTx()) {
+            Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle();
+            if (annotNode != null) {
+                // delete related objects
                 for (Relationship rel : annotNode.getRelationships()) {
                     // delete relation and the related node if it has no other
@@ -808,8 +812,6 @@
                     logger.error("deleteById: unable to delete: Node still has relations.");
                 }
-                tx.success();
-            } finally {
-                tx.finish();
-            }
+            }
+            tx.success();
         }
     }
@@ -826,18 +828,18 @@
         if (targetUri != null) {
             // there should be only one
-            Node target = getNodeFromIndex("uri", targetUri, NodeTypes.TARGET); 
+            Node target = getNodeFromIndex("uri", targetUri, NodeTypes.TARGET);
             if (target != null) {
-                try ( Transaction tx = graphDb.beginTx() ) {
-                Iterable<Relationship> relations = target.getRelationships(RelationTypes.ANNOTATES);
-                for (Relationship relation : relations) {
-                    Node ann = relation.getStartNode();
-                    if (ann.getProperty("TYPE", "").equals("ANNOTATION")) {
-                        Annotation annot = createAnnotationFromNode(ann);
-                        annotations.add(annot);
-                    } else {
-                        logger.error("ANNOTATES relation does not start with ANNOTATION: " + ann);
+                try (Transaction tx = graphDb.beginTx()) {
+                    Iterable<Relationship> relations = target.getRelationships(RelationTypes.ANNOTATES);
+                    for (Relationship relation : relations) {
+                        Node ann = relation.getStartNode();
+                        if (ann.getProperty("TYPE", "").equals("ANNOTATION")) {
+                            Annotation annot = createAnnotationFromNode(ann);
+                            annotations.add(annot);
+                        } else {
+                            logger.error("ANNOTATES relation does not start with ANNOTATION: " + ann);
+                        }
                     }
-                }
-                tx.success();
+                    tx.success();
                 }
             }
@@ -847,18 +849,21 @@
             Node person = getPersonNodeByUri(userUri);
             if (person != null) {
-                Iterable<Relationship> relations = person.getRelationships(RelationTypes.CREATED);
-                for (Relationship relation : relations) {
-                    Node ann = relation.getEndNode();
-                    if (ann.getProperty("TYPE", "").equals("ANNOTATION")) {
-                        Annotation annot = createAnnotationFromNode(ann);
-                        annotations.add(annot);
-                    } else {
-                        logger.error("CREATED relation does not end with ANNOTATION: " + ann);
+                try (Transaction tx = graphDb.beginTx()) {
+                    Iterable<Relationship> relations = person.getRelationships(RelationTypes.CREATED);
+                    for (Relationship relation : relations) {
+                        Node ann = relation.getEndNode();
+                        if (ann.getProperty("TYPE", "").equals("ANNOTATION")) {
+                            Annotation annot = createAnnotationFromNode(ann);
+                            annotations.add(annot);
+                        } else {
+                            logger.error("CREATED relation does not end with ANNOTATION: " + ann);
+                        }
                     }
+                    tx.success();
                 }
             }
         }
         // TODO: if both uri and user are given we should intersect
-        
+
         return annotations;
     }
@@ -874,23 +879,25 @@
      */
     protected Relationship getOrCreateRelation(Node start, RelationshipType type, Node end) {
-        if (start == null || end == null) return null;
+        if (start == null || end == null)
+            return null;
         if (start.hasRelationship()) {
             // there are relations
-            Iterable<Relationship> rels = start.getRelationships(type, Direction.OUTGOING);
-            for (Relationship rel : rels) {
-                if (rel.getEndNode().equals(end)) {
-                    // relation exists
-                    return rel;
-                }
+            try (Transaction tx = graphDb.beginTx()) {
+                Iterable<Relationship> rels = start.getRelationships(type, Direction.OUTGOING);
+                for (Relationship rel : rels) {
+                    if (rel.getEndNode().equals(end)) {
+                        // relation exists
+                        tx.success();
+                        return rel;
+                    }
+                }
+                tx.success();
             }
         }
         // create new one
         Relationship rel;
-        Transaction tx = graphDb.beginTx();
-        try {
+        try (Transaction tx = graphDb.beginTx()) {
             rel = start.createRelationshipTo(end, type);
             tx.success();
-        } finally {
-            tx.finish();
         }
         return rel;
@@ -899,18 +906,16 @@
     protected Node getOrCreateAnnotationNode(String id) {
         Index<Node> idx = getNodeIndex(NodeTypes.ANNOTATION);
-        IndexHits<Node> annotations = idx.get("id", id);
-        Node annotation = annotations.getSingle();
-        if (annotation == null) {
-            // does not exist yet
-            Transaction tx = graphDb.beginTx();
-            try {
+        Node annotation;
+        try (Transaction tx = graphDb.beginTx()) {
+            IndexHits<Node> annotations = idx.get("id", id);
+            annotation = annotations.getSingle();
+            if (annotation == null) {
+                // does not exist yet
                 annotation = graphDb.createNode();
                 annotation.setProperty("TYPE", NodeTypes.ANNOTATION.name());
                 annotation.setProperty("id", id);
                 idx.add(annotation, "id", id);
-                tx.success();
-            } finally {
-                tx.finish();
-            }
+            }
+            tx.success();
         }
         return annotation;
@@ -919,18 +924,16 @@
     protected Node getOrCreateUriNode(String uri, NodeTypes type) {
         Index<Node> idx = getNodeIndex(type);
-        IndexHits<Node> targets = idx.get("uri", uri);
-        Node target = targets.getSingle();
-        if (target == null) {
-            // does not exist yet
-            Transaction tx = graphDb.beginTx();
-            try {
+        Node target;
+        try (Transaction tx = graphDb.beginTx()) {
+            IndexHits<Node> targets = idx.get("uri", uri);
+            target = targets.getSingle();
+            if (target == null) {
+                // does not exist yet
                 target = graphDb.createNode();
                 target.setProperty("TYPE", type.name());
                 target.setProperty("uri", uri);
                 idx.add(target, "uri", uri);
-                tx.success();
-            } finally {
-                tx.finish();
-            }
+            }
+            tx.success();
         }
         return target;
@@ -941,4 +944,5 @@
         String uri = actor.getUriString();
         Index<Node> idx;
+        Node person;
         if (actor.isGroup()) {
             idx = getNodeIndex(NodeTypes.GROUP);
@@ -946,6 +950,9 @@
             idx = getNodeIndex(NodeTypes.PERSON);
         }
-        IndexHits<Node> persons = idx.get("uri", uri);
-        Node person = persons.getSingle();
+        try (Transaction tx = graphDb.beginTx()) {
+            IndexHits<Node> persons = idx.get("uri", uri);
+            person = persons.getSingle();
+            tx.success();
+        }
         return person;
     }
@@ -956,16 +963,16 @@
         String name = actor.getName();
         String id = actor.getId();
-        Index<Node> idx;
-        if (actor.isGroup()) {
-            idx = getNodeIndex(NodeTypes.GROUP);
-        } else {
-            idx = getNodeIndex(NodeTypes.PERSON);
-        }
-        IndexHits<Node> persons = idx.get("uri", uri);
-        Node person = persons.getSingle();
-        if (person == null) {
-            // does not exist yet
-            Transaction tx = graphDb.beginTx();
-            try {
+        Node person;
+        try (Transaction tx = graphDb.beginTx()) {
+            Index<Node> idx;
+            if (actor.isGroup()) {
+                idx = getNodeIndex(NodeTypes.GROUP);
+            } else {
+                idx = getNodeIndex(NodeTypes.PERSON);
+            }
+            IndexHits<Node> persons = idx.get("uri", uri);
+            person = persons.getSingle();
+            if (person == null) {
+                // does not exist yet
                 person = graphDb.createNode();
                 if (actor.isGroup()) {
@@ -982,8 +989,6 @@
                     person.setProperty("id", id);
                 }
-                tx.success();
-            } finally {
-                tx.finish();
-            }
+            }
+            tx.success();
         }
         return person;
@@ -993,10 +998,10 @@
         Index<Node> idx = getNodeIndex(NodeTypes.TAG);
         String tagname = inTag.getName();
-        IndexHits<Node> tags = idx.get("name", tagname);
-        Node tag = tags.getSingle();
-        if (tag == null) {
-            // does not exist yet
-            Transaction tx = graphDb.beginTx();
-            try {
+        Node tag;
+        try (Transaction tx = graphDb.beginTx()) {
+            IndexHits<Node> tags = idx.get("name", tagname);
+            tag = tags.getSingle();
+            if (tag == null) {
+                // does not exist yet
                 tag = graphDb.createNode();
                 tag.setProperty("TYPE", NodeTypes.TAG.name());
@@ -1007,9 +1012,6 @@
                 tag.setProperty("uri", inTag.getUri());
                 idx.add(tag, "uri", inTag.getUri());
-
-                tx.success();
-            } finally {
-                tx.finish();
-            }
+            }
+            tx.success();
         }
         return tag;
@@ -1031,17 +1033,15 @@
         if (rel != null) {
             // relation exists
-            Node oldActorNode = rel.getEndNode();
-            if (!oldActorNode.equals(newActorNode)) {
-                // new admin is different
-                Transaction tx = graphDb.beginTx();
-                try {
+            try (Transaction tx = graphDb.beginTx()) {
+                Node oldActorNode = rel.getEndNode();
+                if (!oldActorNode.equals(newActorNode)) {
+                    // new admin is different
                     rel.delete();
                     tx.success();
-                } finally {
-                    tx.finish();
                 }
                 if (newActorNode != null) {
                     rel = getOrCreateRelation(annotNode, type, newActorNode);
                 }
+                tx.success();
             }
         } else {
@@ -1059,6 +1059,5 @@
      */
     protected void deleteNode(Node node) {
-        Transaction tx = graphDb.beginTx();
-        try {
+        try (Transaction tx = graphDb.beginTx()) {
             if (node.hasRelationship()) {
                 logger.error("deleteNode: unable to delete: Node still has relations.");
@@ -1074,6 +1073,4 @@
             }
             tx.success();
-        } finally {
-            tx.finish();
         }
     }
@@ -1089,13 +1086,16 @@
     protected Relationship getRelation(Node start, RelationTypes type, Direction direction) {
         Iterable<Relationship> rels;
-        if (direction == null) {
-            // ignore direction
-            rels = start.getRelationships(type);
-        } else {
-            rels = start.getRelationships(type, direction);
-        }
-        for (Relationship rel : rels) {
-            // just the first one
-            return rel;
+        try (Transaction tx = graphDb.beginTx()) {
+            if (direction == null) {
+                // ignore direction
+                rels = start.getRelationships(type);
+            } else {
+                rels = start.getRelationships(type, direction);
+            }
+            tx.success();
+            for (Relationship rel : rels) {
+                // just the first one
+                return rel;
+            }
         }
         return null;
@@ -1117,8 +1117,11 @@
         Node tag = getTagNodeByUri(tagUri);
         if (tag != null) {
-            Iterable<Relationship> rels = tag.getRelationships(Direction.INCOMING, RelationTypes.HAS_TAG);
-            for (Relationship rel : rels) {
-                Node node = rel.getStartNode();
-                ret.add(createAnnotationFromNode(node));
+            try (Transaction tx = graphDb.beginTx()) {
+                Iterable<Relationship> rels = tag.getRelationships(Direction.INCOMING, RelationTypes.HAS_TAG);
+                for (Relationship rel : rels) {
+                    Node node = rel.getStartNode();
+                    ret.add(createAnnotationFromNode(node));
+                }
+                tx.success();
             }
         }
@@ -1130,12 +1133,15 @@
         Node res = getNodeFromIndex("uri", resourceUri, NodeTypes.RESOURCE);
         if (res != null) {
-            Iterable<Relationship> rels = res.getRelationships(Direction.INCOMING, RelationTypes.ANNOTATES);
-            for (Relationship rel : rels) {
-                Node an = rel.getStartNode();
-                Node rn = rel.getEndNode();
-                if (rn.getProperty("TYPE", "").equals("RESOURCE")) {
-                    logger.error("getAnnotationsByResource got ANNOTATES != RESOURCE");
-                }
-                ret.add(createAnnotationFromNode(an));
+            try (Transaction tx = graphDb.beginTx()) {
+                Iterable<Relationship> rels = res.getRelationships(Direction.INCOMING, RelationTypes.ANNOTATES);
+                for (Relationship rel : rels) {
+                    Node an = rel.getStartNode();
+                    Node rn = rel.getEndNode();
+                    if (rn.getProperty("TYPE", "").equals("RESOURCE")) {
+                        logger.error("getAnnotationsByResource got ANNOTATES != RESOURCE");
+                    }
+                    ret.add(createAnnotationFromNode(an));
+                }
+                tx.success();
             }
         }
Index: src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorRestlet.java
===================================================================
--- src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorRestlet.java	(revision 63)
+++ src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorRestlet.java	(revision 68)
@@ -15,5 +15,5 @@
 public class AnnotatorRestlet extends BaseRestlet {
 
-    public final String version = "AnnotationManagerN4J/Annotator 0.3.1";
+    public final String version = "AnnotationManagerN4J/Annotator 0.3.2";
 
     public static Logger logger = Logger.getLogger(AnnotatorRestlet.class);
Index: src/main/webapp/annotationBrowser/js/annotation.js
===================================================================
--- src/main/webapp/annotationBrowser/js/annotation.js	(revision 37)
+++ src/main/webapp/annotationBrowser/js/annotation.js	(revision 68)
@@ -20,5 +20,5 @@
 		  for (var i=0;i<rows.length;i++){
 			  var text=rows[i]['text'];
-			  var author=rows[i]['user']['name'];
+			  var author= (rows[i]['user'] != null) ? rows[i]['user']['name'] : 'NO USER';
 			  var docUri=createLinkFromURI(rows[i]['uri']);
 			  
