diff --git a/src/main/java/org/caosdb/server/CaosDBServer.java b/src/main/java/org/caosdb/server/CaosDBServer.java
index c7b461d50ceb353ea3ac0881b40b391276caffea..82d79177e0536bde488778333c4dceba44e70d04 100644
--- a/src/main/java/org/caosdb/server/CaosDBServer.java
+++ b/src/main/java/org/caosdb/server/CaosDBServer.java
@@ -141,7 +141,7 @@ public class CaosDBServer extends Application {
   public static void main(final String[] args)
       throws SecurityException, FileNotFoundException, IOException {
     try {
-      init(args);
+      parseArguments(args);
       initScheduler();
       initServerProperties();
       initTimeZone();
@@ -156,9 +156,18 @@ public class CaosDBServer extends Application {
     }
   }
 
-  private static void init(final String[] args) {
-    // Important change:
-    // Make silent the default option
+  /**
+   * Parse the command line arguments.
+   *
+   * <p>- "nobackend": flag to run caosdb without any backend (for testing purposes) - "insecure":
+   * flag to start only a http server (no https server)
+   *
+   * <p>Both flags are only available in the debug mode which is controlled by the `caosdb.debug`
+   * JVM Property.
+   *
+   * @param args
+   */
+  private static void parseArguments(final String[] args) {
     for (final String s : args) {
       if (s.equals("nobackend")) {
         START_BACKEND = false;
diff --git a/src/main/java/org/caosdb/server/database/BackendTransaction.java b/src/main/java/org/caosdb/server/database/BackendTransaction.java
index 5bf978343d72272309d4f4ab0f039770419c87b8..edf9b16f8a554a52b667e92d87944ec0b27e4647 100644
--- a/src/main/java/org/caosdb/server/database/BackendTransaction.java
+++ b/src/main/java/org/caosdb/server/database/BackendTransaction.java
@@ -129,6 +129,8 @@ import org.caosdb.server.database.backend.interfaces.UpdateUserImpl;
 import org.caosdb.server.database.backend.interfaces.UpdateUserRolesImpl;
 import org.caosdb.server.database.exceptions.TransactionException;
 import org.caosdb.server.database.misc.TransactionBenchmark;
+import org.caosdb.server.entity.EntityInterface;
+import org.caosdb.server.entity.RetrieveEntity;
 import org.caosdb.server.utils.UndoHandler;
 import org.caosdb.server.utils.Undoable;
 
@@ -295,4 +297,9 @@ public abstract class BackendTransaction implements Undoable {
       this.benchmark.addMeasurement(o, time);
     }
   }
+
+  /** Returns the type of transaction of an entity, e.g. "Retrieve" for a {@link RetrieveEntity}. */
+  public String getTransactionType(EntityInterface e) {
+    return e.getClass().getSimpleName().replace("Entity", "");
+  }
 }
diff --git a/src/main/java/org/caosdb/server/database/backend/transaction/InsertTransactionHistory.java b/src/main/java/org/caosdb/server/database/backend/transaction/InsertTransactionHistory.java
index 47db0e7feddfaa3ae390c71615b7f1efed989906..9b798de4279de8034168c4ecfbc1738c70370a65 100644
--- a/src/main/java/org/caosdb/server/database/backend/transaction/InsertTransactionHistory.java
+++ b/src/main/java/org/caosdb/server/database/backend/transaction/InsertTransactionHistory.java
@@ -30,6 +30,11 @@ import org.caosdb.server.entity.EntityInterface;
 import org.caosdb.server.entity.container.TransactionContainer;
 import org.caosdb.server.utils.EntityStatus;
 
+/**
+ * Record the current transaction in the entities transaction history.
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public class InsertTransactionHistory extends BackendTransaction {
 
   private final TransactionContainer container;
@@ -57,7 +62,7 @@ public class InsertTransactionHistory extends BackendTransaction {
           || e.getEntityStatus() == EntityStatus.VALID) {
 
         t.execute(
-            e.getClass().getSimpleName().replace("Entity", ""),
+            getTransactionType(e),
             this.realm,
             this.user,
             this.datetime.getUTCSeconds(),
diff --git a/src/main/java/org/caosdb/server/database/backend/transaction/RuleLoader.java b/src/main/java/org/caosdb/server/database/backend/transaction/RuleLoader.java
index d9e7794d4e91e2d6fafd0fb96b7dbdf711af0450..c73023bd4429db19ca0a968aa99b657f0d0cbea4 100644
--- a/src/main/java/org/caosdb/server/database/backend/transaction/RuleLoader.java
+++ b/src/main/java/org/caosdb/server/database/backend/transaction/RuleLoader.java
@@ -37,6 +37,12 @@ import org.caosdb.server.entity.wrapper.Property;
 import org.caosdb.server.jobs.Job;
 import org.caosdb.server.transaction.Transaction;
 
+/**
+ * Load transaction rules (e.g. "Referenced entities must always exist") and their configuration
+ * from the back-end.
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public class RuleLoader extends CacheableBackendTransaction<String, ArrayList<Rule>> {
 
   private static final ICacheAccess<String, ArrayList<Rule>> cache =
@@ -58,10 +64,9 @@ public class RuleLoader extends CacheableBackendTransaction<String, ArrayList<Ru
     this.entity = entity;
     this.e = e;
     if (e instanceof Property) {
-      this.transactionType =
-          ((Property) e).getDomainEntity().getClass().getSimpleName().replace("Entity", "");
+      this.transactionType = getTransactionType(((Property) e).getDomainEntity());
     } else {
-      this.transactionType = e.getClass().getSimpleName().replace("Entity", "");
+      this.transactionType = getTransactionType(e);
     }
     this.transaction = transaction;
   }
diff --git a/src/main/java/org/caosdb/server/entity/container/DeleteContainer.java b/src/main/java/org/caosdb/server/entity/container/DeleteContainer.java
deleted file mode 100644
index 2b7406255e46227aa9d48b9f8fe132a08742a096..0000000000000000000000000000000000000000
--- a/src/main/java/org/caosdb/server/entity/container/DeleteContainer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package caosdb.server.entity.container;
-//
-// import caosdb.server.entity.DeleteEntity;
-// import java.util.HashMap;
-// import org.apache.shiro.subject.Subject;
-//
-// public class DeleteContainer extends EntityByIdContainer {
-//
-//  private static final long serialVersionUID = 4113458285424498764L;
-//
-//  public DeleteContainer(
-//      final Subject user,
-//      final Long timestamp,
-//      final String srid,
-//      final HashMap<String, String> flags) {
-//    super(user, timestamp, srid, flags);
-//  }
-//
-//  @Override
-//  public void add(final int id) {
-//    add(new DeleteEntity(id));
-//  }
-//
-//  @Override
-//  public void add(int id, String version) {
-//    add(new DeleteEntity(id, version));
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/entity/container/InsertContainer.java b/src/main/java/org/caosdb/server/entity/container/InsertContainer.java
deleted file mode 100644
index 794e7c4b4a799dacadb66cea6a5abedacdeb5f3e..0000000000000000000000000000000000000000
--- a/src/main/java/org/caosdb/server/entity/container/InsertContainer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package caosdb.server.entity.container;
-//
-// import java.util.HashMap;
-// import org.apache.shiro.subject.Subject;
-//
-// public class InsertContainer extends WritableContainer {
-//
-//  public InsertContainer(
-//      final Subject user,
-//      final Long timestamp,
-//      final String srid,
-//      final HashMap<String, String> flags) {
-//    super(user, timestamp, srid, flags);
-//  }
-//
-//  private static final long serialVersionUID = -5264959991145009088L;
-//
-//
-// }
diff --git a/src/main/java/org/caosdb/server/entity/container/UpdateContainer.java b/src/main/java/org/caosdb/server/entity/container/UpdateContainer.java
deleted file mode 100644
index 41ea8afbcdf5acff2e38339e691d68906413a44a..0000000000000000000000000000000000000000
--- a/src/main/java/org/caosdb/server/entity/container/UpdateContainer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package caosdb.server.entity.container;
-//
-// import caosdb.server.entity.UpdateEntity;
-// import java.util.HashMap;
-// import org.apache.shiro.subject.Subject;
-// import org.jdom2.Element;
-//
-// public class UpdateContainer extends WritableContainer {
-//
-//  private static final long serialVersionUID = -4571405395722707413L;
-//
-//  public UpdateContainer(
-//      final Subject user,
-//      final Long timestamp,
-//      final String srid,
-//      final HashMap<String, String> flags) {
-//    super(user, timestamp, srid, flags);
-//  }
-//
-//  @Override
-//  public void add(final Element entity) {
-//    add(new UpdateEntity(entity));
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/jobs/core/InsertFilesInDir.java b/src/main/java/org/caosdb/server/jobs/core/InsertFilesInDir.java
index cde08268e53509b4af70e3a10981def7c97de6f3..4aedc0cb78e077d2e0e5f492dd7cb280b8638285 100644
--- a/src/main/java/org/caosdb/server/jobs/core/InsertFilesInDir.java
+++ b/src/main/java/org/caosdb/server/jobs/core/InsertFilesInDir.java
@@ -211,7 +211,7 @@ public class InsertFilesInDir extends FlagJob {
         } else {
           i++;
           final String targetPath = root + sub.getName();
-          final EntityInterface newFileEntity = createEntity(sub.getName());
+          final EntityInterface newFileEntity = createInsertFileEntity(sub.getName());
           final long size = sub.length();
           final FileProperties fp = new FileProperties(null, targetPath, size);
           newFileEntity.setFileProperties(fp);
@@ -256,7 +256,14 @@ public class InsertFilesInDir extends FlagJob {
     return i;
   }
 
-  private EntityInterface createEntity(String name) {
+  /**
+   * Create a new InsertEntity (if this is an actual run) or a new RetrieveEntity (in dry-run mode)
+   * with {@link Role.File}.
+   *
+   * @param name the file name
+   * @return new File entity
+   */
+  private EntityInterface createInsertFileEntity(String name) {
     if (getTransaction() instanceof WriteTransactionInterface) {
       return new InsertEntity(name, Role.File);
     }
diff --git a/src/main/java/org/caosdb/server/resource/EntityOwnerResource.java b/src/main/java/org/caosdb/server/resource/EntityOwnerResource.java
index 853780fcdf118c4e26ee62e857f863d29d5f13fc..41f92a5631d9cabb04ee5498373848b516885424 100644
--- a/src/main/java/org/caosdb/server/resource/EntityOwnerResource.java
+++ b/src/main/java/org/caosdb/server/resource/EntityOwnerResource.java
@@ -4,6 +4,8 @@
  *
  * Copyright (C) 2018 Research Group Biomedical Physics,
  * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
+ * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
+ * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -24,14 +26,23 @@ package org.caosdb.server.resource;
 
 import org.caosdb.server.entity.EntityInterface;
 import org.caosdb.server.entity.container.RetrieveContainer;
+import org.caosdb.server.permissions.EntityPermission;
 import org.caosdb.server.resource.transaction.RetrieveEntityResource;
 
+/**
+ * Resource which returns the entity with the owner information attached to it.
+ *
+ * <p>Note: 'Owners' are all roles with the {@link EntityPermission#EDIT_ACL}
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public class EntityOwnerResource extends RetrieveEntityResource {
 
   @Override
   protected void handleRetrieveContainer(RetrieveContainer container) {
     super.handleRetrieveContainer(container);
     for (final EntityInterface e : container) {
+      // with this flag, the owner info will be loaded as well.
       e.setFlag("owner", null);
     }
   }
diff --git a/src/main/java/org/caosdb/server/resource/EntityPermissionsResource.java b/src/main/java/org/caosdb/server/resource/EntityPermissionsResource.java
index cd06f73dec6e267ec273abc1256d644794a9637e..1f5ee5f7d8a28a235de02bbc33f826da32af0615 100644
--- a/src/main/java/org/caosdb/server/resource/EntityPermissionsResource.java
+++ b/src/main/java/org/caosdb/server/resource/EntityPermissionsResource.java
@@ -4,6 +4,8 @@
  *
  * Copyright (C) 2018 Research Group Biomedical Physics,
  * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
+ * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
+ * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -26,6 +28,12 @@ import org.caosdb.server.entity.container.RetrieveContainer;
 import org.caosdb.server.permissions.EntityPermission;
 import org.caosdb.server.resource.transaction.RetrieveEntityResource;
 
+/**
+ * Resource which appends the entity permissions (esp. the global ones) to the normal entity
+ * response.
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public class EntityPermissionsResource extends RetrieveEntityResource {
 
   @Override
diff --git a/src/main/java/org/caosdb/server/resource/transaction/EntityNamesResource.java b/src/main/java/org/caosdb/server/resource/transaction/EntityNamesResource.java
index 18dac7b929a4d1d2afc9081e7f1800b899a890f2..0c66485ea3d62286d633d9580c1362ba33435095 100644
--- a/src/main/java/org/caosdb/server/resource/transaction/EntityNamesResource.java
+++ b/src/main/java/org/caosdb/server/resource/transaction/EntityNamesResource.java
@@ -1,7 +1,36 @@
+/*
+ * ** header v3.0
+ * This file is a part of the CaosDB Project.
+ *
+ * Copyright (C) 2018 Research Group Biomedical Physics,
+ * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
+ * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
+ * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * ** end header
+ */
 package org.caosdb.server.resource.transaction;
 
 import org.caosdb.server.entity.container.RetrieveContainer;
 
+/**
+ * Resource which returns only the names of entities.
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public class EntityNamesResource extends RetrieveEntityResource {
 
   @Override
diff --git a/src/main/java/org/caosdb/server/resource/transaction/EntityResource.java b/src/main/java/org/caosdb/server/resource/transaction/EntityResource.java
index da01d6f7890604ac8612fb0b8dc931ba53e4771d..704fcfb9aa92e56ad963365d763f70fa7feb470e 100644
--- a/src/main/java/org/caosdb/server/resource/transaction/EntityResource.java
+++ b/src/main/java/org/caosdb/server/resource/transaction/EntityResource.java
@@ -4,6 +4,8 @@
  *
  * Copyright (C) 2018 Research Group Biomedical Physics,
  * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
+ * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
+ * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -48,8 +50,16 @@ import org.restlet.data.MediaType;
 import org.restlet.ext.fileupload.RestletFileUpload;
 import org.restlet.representation.Representation;
 
+/**
+ * Handles POST, PUT, and DELETE requests for Entities.
+ *
+ * <p>The GET requests (Retrieval) is handled in the superclass {@link RetrieveEntityResource}.
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public class EntityResource extends RetrieveEntityResource {
 
+  /** Handle entity deletions (DELETE requests). */
   @Override
   protected final Representation httpDeleteInChildClass() throws Exception {
 
@@ -85,6 +95,7 @@ public class EntityResource extends RetrieveEntityResource {
     return ok(doc);
   }
 
+  /** Handle entity insertions (POST requests). */
   @Override
   protected final Representation httpPostInChildClass(final Representation entity)
       throws xmlNotWellFormedException, Exception {
@@ -115,6 +126,10 @@ public class EntityResource extends RetrieveEntityResource {
     return ok(doc);
   }
 
+  /**
+   * Parse the body of requests with content type "multipart/form-data". This is specific for
+   * requests which also contain file blobs.
+   */
   private Element parseMultipartEntity(WritableContainer container)
       throws FileUploadException, IOException, Message, xmlNotWellFormedException,
           NoSuchAlgorithmException, CaosDBException {
@@ -150,6 +165,7 @@ public class EntityResource extends RetrieveEntityResource {
     return element;
   }
 
+  /** Handle entity updates (PUT requests). */
   @Override
   protected final Representation httpPutInChildClass(final Representation entity)
       throws ConnectionException, JDOMException, Exception, xmlNotWellFormedException {
diff --git a/src/main/java/org/caosdb/server/resource/transaction/RetrieveEntityResource.java b/src/main/java/org/caosdb/server/resource/transaction/RetrieveEntityResource.java
index c9312f8f7f0ed39de3dfc5087f453092681be2f3..5eb9db72f69f8f054dbb6f02b970d09e09ff366c 100644
--- a/src/main/java/org/caosdb/server/resource/transaction/RetrieveEntityResource.java
+++ b/src/main/java/org/caosdb/server/resource/transaction/RetrieveEntityResource.java
@@ -1,3 +1,27 @@
+/*
+ * ** header v3.0
+ * This file is a part of the CaosDB Project.
+ *
+ * Copyright (C) 2018 Research Group Biomedical Physics,
+ * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
+ * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
+ * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * ** end header
+ */
 package org.caosdb.server.resource.transaction;
 
 import java.io.IOException;
@@ -12,8 +36,19 @@ import org.jdom2.Document;
 import org.jdom2.Element;
 import org.restlet.representation.Representation;
 
+/**
+ * Handles GET requests for different subclasses which all have in common that they retrieve
+ * Entities (plus other information in some cases).
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public abstract class RetrieveEntityResource extends AbstractCaosDBServerResource {
 
+  /**
+   * Parse the segment which specifies the entities which are to be retrieved
+   *
+   * @param container
+   */
   protected void handleRetrieveContainer(RetrieveContainer container) {
 
     for (final String item : getRequestedItems()) {
@@ -38,6 +73,7 @@ public abstract class RetrieveEntityResource extends AbstractCaosDBServerResourc
     }
   }
 
+  /** Handle the GET request. */
   @Override
   protected final Representation httpGetInChildClass()
       throws ConnectionException, IOException, SQLException, CaosDBException,
diff --git a/src/main/java/org/caosdb/server/transaction/WriteTransaction.java b/src/main/java/org/caosdb/server/transaction/WriteTransaction.java
index 2a43e71074318cddec0d4e503a48b2380588cc30..c54eb6f77ffb1ec6767088047f97e28db975788d 100644
--- a/src/main/java/org/caosdb/server/transaction/WriteTransaction.java
+++ b/src/main/java/org/caosdb/server/transaction/WriteTransaction.java
@@ -32,6 +32,7 @@ import java.util.Set;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.authz.AuthorizationException;
 import org.caosdb.server.CaosDBException;
+import org.caosdb.server.database.BackendTransaction;
 import org.caosdb.server.database.access.Access;
 import org.caosdb.server.database.backend.transaction.DeleteEntityTransaction;
 import org.caosdb.server.database.backend.transaction.InsertEntityTransaction;
@@ -48,12 +49,25 @@ import org.caosdb.server.entity.container.TransactionContainer;
 import org.caosdb.server.entity.container.WritableContainer;
 import org.caosdb.server.entity.wrapper.Parent;
 import org.caosdb.server.entity.wrapper.Property;
+import org.caosdb.server.jobs.Schedule;
 import org.caosdb.server.permissions.EntityACL;
 import org.caosdb.server.permissions.EntityPermission;
 import org.caosdb.server.permissions.Permission;
 import org.caosdb.server.utils.EntityStatus;
 import org.caosdb.server.utils.ServerMessages;
 
+/**
+ * This class is responsible for inserting, updating and deleting entities which are held in the
+ * {@link TransactionContainer}.
+ *
+ * <p>This class initializes and run the {@link Schedule} of {@link Job}s, calls the {@link
+ * BackendTransaction}s for each entity, and handles exceptions, roll-back (if necessary) and clean
+ * up afterwards.
+ *
+ * <p>It initializes and runs the schedule of jobs which
+ *
+ * @author Timm Fitschen (t.fitschen@indiscale.com)
+ */
 public class WriteTransaction extends Transaction<WritableContainer>
     implements WriteTransactionInterface {
 
@@ -115,6 +129,7 @@ public class WriteTransaction extends Transaction<WritableContainer>
   protected void init() throws Exception {
     // collect all ids of the entities which are to be updated.
     final TransactionContainer oldContainer = new TransactionContainer();
+    // collect all ids of the entities which are to be deleted.
     final TransactionContainer deleteContainer = new TransactionContainer();
     for (final EntityInterface entity : getContainer()) {
       if (entity instanceof UpdateEntity) {
@@ -163,8 +178,6 @@ public class WriteTransaction extends Transaction<WritableContainer>
                   && entity.getFileProperties().hasTmpIdentifier()
                   && !entity.getFileProperties().isPickupable()) {
 
-                // TODO
-                // if (newEntity.getFileProperties().getTmpIdentifier() != null) {
                 // get file by tmpIdentifier
                 final FileProperties f =
                     getContainer().getFiles().get(entity.getFileProperties().getTmpIdentifyer());
@@ -291,6 +304,9 @@ public class WriteTransaction extends Transaction<WritableContainer>
   @Override
   protected void transaction() throws Exception {
     if (getContainer().getStatus().ordinal() >= EntityStatus.QUALIFIED.ordinal()) {
+
+      // split up the TransactionContainer into three containers, one for each
+      // type of writing transaction.
       TransactionContainer inserts = new TransactionContainer();
       TransactionContainer updates = new TransactionContainer();
       TransactionContainer deletes = new TransactionContainer();
@@ -303,16 +319,20 @@ public class WriteTransaction extends Transaction<WritableContainer>
           deletes.add(entity);
         }
       }
+
+      // The order is crucial: 1) Update-entities may reference new entities which
+      // have to be inserted first. 2) Update-Entities which (originally)
+      // reference old entities which are to be deleted, have be updated before
+      // the others can be deleted.
       insert(inserts, getAccess());
       update(updates, getAccess());
       delete(deletes, getAccess());
-      // TODO RETRIEVE
     }
   }
 
   @Override
   protected void postTransaction() throws Exception {
-    // set entityStatus to DELETED and add deletion info message
+    // set entityStatus to DELETED and add deletion info message for deleted entities.
     if (getContainer().getStatus().ordinal() >= EntityStatus.QUALIFIED.ordinal()) {
       for (final EntityInterface entity : getContainer()) {
         if (entity instanceof DeleteEntity && entity.getEntityStatus() == EntityStatus.VALID) {
diff --git a/src/test/java/org/caosdb/server/database/backend/transaction/BackendTransactionTest.java b/src/test/java/org/caosdb/server/database/backend/transaction/BackendTransactionTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..93402bf0d06c487451d9219b4487f301eb855f49
--- /dev/null
+++ b/src/test/java/org/caosdb/server/database/backend/transaction/BackendTransactionTest.java
@@ -0,0 +1,24 @@
+package org.caosdb.server.database.backend.transaction;
+
+import static org.junit.Assert.assertEquals;
+
+import org.caosdb.server.database.BackendTransaction;
+import org.caosdb.server.entity.DeleteEntity;
+import org.caosdb.server.entity.InsertEntity;
+import org.caosdb.server.entity.RetrieveEntity;
+import org.caosdb.server.entity.Role;
+import org.caosdb.server.entity.UpdateEntity;
+import org.jdom2.Element;
+import org.junit.Test;
+
+public class BackendTransactionTest {
+
+  @Test
+  public void testGetTransactionType() {
+    BackendTransaction transaction = new InsertTransactionHistory(null, null, null, null);
+    assertEquals("Retrieve", transaction.getTransactionType(new RetrieveEntity("test")));
+    assertEquals("Insert", transaction.getTransactionType(new InsertEntity("test", Role.Record)));
+    assertEquals("Delete", transaction.getTransactionType(new DeleteEntity(1234)));
+    assertEquals("Update", transaction.getTransactionType(new UpdateEntity(new Element("Record"))));
+  }
+}