From 1c30ba894ac2eb9060498c0848c8e86469d313d7 Mon Sep 17 00:00:00 2001
From: Daniel Gerhardt <code@dgerhardt.net>
Date: Wed, 19 Jul 2017 15:15:16 +0200
Subject: [PATCH] Refactor repository method signatures and variable names

* Prefer ids over "foreign" domain objects.
* Consistently use final keyword for implementation parameters and
  variables.
* As a consequence, session id is used instead of the object as cache
  key for `skillquestions`, `lecturequestions`, `preparationquestions`
  and`flashcardquestions` caches.
* Rename occurances of `questionId` to `contentId`.
---
 .../arsnova/persistance/AnswerRepository.java |  27 +-
 .../persistance/CommentRepository.java        |  15 +-
 .../persistance/ContentRepository.java        |  63 +++--
 .../persistance/LogEntryRepository.java       |   8 +-
 .../persistance/MotdListRepository.java       |   2 +-
 .../arsnova/persistance/MotdRepository.java   |   2 +-
 .../persistance/SessionRepository.java        |  14 +-
 .../couchdb/CouchDbAnswerRepository.java      | 139 +++++-----
 .../couchdb/CouchDbCommentRepository.java     |  49 ++--
 .../couchdb/CouchDbContentRepository.java     | 241 +++++++++---------
 .../couchdb/CouchDbLogEntryRepository.java    |   6 +-
 .../couchdb/CouchDbMotdListRepository.java    |   8 +-
 .../couchdb/CouchDbMotdRepository.java        |  16 +-
 .../couchdb/CouchDbSessionRepository.java     | 178 ++++++-------
 .../CouchDbSessionStatisticsRepository.java   |  10 +-
 .../couchdb/CouchDbStatisticsRepository.java  |   8 +-
 .../couchdb/CouchDbUserRepository.java        |  20 +-
 .../CouchDbVisitedSessionRepository.java      |  14 +-
 .../couchdb/InitializingCouchDbConnector.java |  18 +-
 .../arsnova/services/CommentServiceImpl.java  |  14 +-
 .../arsnova/services/ContentServiceImpl.java  |  86 +++----
 src/site/markdown/development/caching.md      |   8 +-
 22 files changed, 471 insertions(+), 475 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/persistance/AnswerRepository.java b/src/main/java/de/thm/arsnova/persistance/AnswerRepository.java
index 27693fa2b..34f363c34 100644
--- a/src/main/java/de/thm/arsnova/persistance/AnswerRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/AnswerRepository.java
@@ -27,23 +27,22 @@ import java.util.List;
 public interface AnswerRepository {
 	Answer get(String id);
 	Answer getMyAnswer(User me, String questionId, int piRound);
-	List<Answer> getAnswers(Content content, int piRound);
-	List<Answer> getAnswers(Content content);
-	List<Answer> getAllAnswers(Content content);
-	int getAnswerCount(Content content, int piRound);
-	int getTotalAnswerCountByQuestion(Content content);
-	int getAbstentionAnswerCount(String questionId);
-	List<Answer> getFreetextAnswers(String questionId, final int start, final int limit);
-	List<Answer> getMyAnswers(User me, Session session);
+	List<Answer> getAnswers(String contentId, int piRound);
+	List<Answer> getAllAnswers(String contentId);
+	int getAnswerCount(String contentId, int round);
+	int getTotalAnswerCountByQuestion(String contentId);
+	int getAbstentionAnswerCount(String contentId);
+	List<Answer> getFreetextAnswers(String contentId, int start, int limit);
+	List<Answer> getMyAnswers(User user, String sessionId);
 	int getTotalAnswerCount(String sessionKey);
-	int deleteAnswers(Content content);
+	int deleteAnswers(String contentId);
 	Answer saveAnswer(Answer answer, User user, Content content, Session session);
 	Answer updateAnswer(Answer answer);
 	void deleteAnswer(String answerId);
-	int countLectureQuestionAnswers(Session session);
-	int countPreparationQuestionAnswers(Session session);
-	int deleteAllQuestionsAnswers(Session session);
-	int deleteAllPreparationAnswers(Session session);
-	int deleteAllLectureAnswers(Session session);
+	int countLectureQuestionAnswers(String sessionId);
+	int countPreparationQuestionAnswers(String sessionId);
+	int deleteAllQuestionsAnswers(String sessionId);
+	int deleteAllPreparationAnswers(String sessionId);
+	int deleteAllLectureAnswers(String sessionId);
 	int[] deleteAllAnswersWithQuestions(List<Content> contents);
 }
diff --git a/src/main/java/de/thm/arsnova/persistance/CommentRepository.java b/src/main/java/de/thm/arsnova/persistance/CommentRepository.java
index c5f8bc350..182066fec 100644
--- a/src/main/java/de/thm/arsnova/persistance/CommentRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/CommentRepository.java
@@ -2,21 +2,20 @@ package de.thm.arsnova.persistance;
 
 import de.thm.arsnova.entities.Comment;
 import de.thm.arsnova.entities.CommentReadingCount;
-import de.thm.arsnova.entities.Session;
 import de.thm.arsnova.entities.User;
 
 import java.util.List;
 
 public interface CommentRepository {
 	int getInterposedCount(String sessionKey);
-	CommentReadingCount getInterposedReadingCount(Session session);
-	CommentReadingCount getInterposedReadingCount(Session session, User user);
-	List<Comment> getInterposedQuestions(Session session, final int start, final int limit);
-	List<Comment> getInterposedQuestions(Session session, User user, final int start, final int limit);
+	CommentReadingCount getInterposedReadingCount(String sessionId);
+	CommentReadingCount getInterposedReadingCount(String sessionId, User user);
+	List<Comment> getInterposedQuestions(String sessionId, int start, int limit);
+	List<Comment> getInterposedQuestions(String sessionId, User user, int start, int limit);
 	Comment getInterposedQuestion(String commentId);
-	Comment saveQuestion(Session session, Comment comment, User user);
+	Comment saveQuestion(String sessionId, Comment comment, User user);
 	void markInterposedQuestionAsRead(Comment comment);
 	void deleteInterposedQuestion(Comment comment);
-	int deleteAllInterposedQuestions(Session session);
-	int deleteAllInterposedQuestions(Session session, User user);
+	int deleteAllInterposedQuestions(String sessionId);
+	int deleteAllInterposedQuestions(String sessionId, User user);
 }
diff --git a/src/main/java/de/thm/arsnova/persistance/ContentRepository.java b/src/main/java/de/thm/arsnova/persistance/ContentRepository.java
index 9c49aa789..e2438013e 100644
--- a/src/main/java/de/thm/arsnova/persistance/ContentRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/ContentRepository.java
@@ -1,7 +1,6 @@
 package de.thm.arsnova.persistance;
 
 import de.thm.arsnova.entities.Content;
-import de.thm.arsnova.entities.Session;
 import de.thm.arsnova.entities.User;
 
 import java.util.List;
@@ -9,36 +8,36 @@ import java.util.List;
 public interface ContentRepository {
 	List<Content> getQuestions(Object... keys);
 	Content getQuestion(String id);
-	Content saveQuestion(Session session, Content content);
-	List<Content> getSkillQuestionsForUsers(Session session);
-	List<Content> getSkillQuestionsForTeachers(Session session);
-	int getSkillQuestionCount(Session session);
-	List<String> getQuestionIds(Session session, User user);
-	int deleteQuestionWithAnswers(Content content);
-	int[] deleteAllQuestionsWithAnswers(Session session);
-	List<String> getUnAnsweredQuestionIds(Session session, User user);
+	Content saveQuestion(String sessionId, Content content);
+	List<Content> getSkillQuestionsForUsers(String sessionId);
+	List<Content> getSkillQuestionsForTeachers(String sessionId);
+	int getSkillQuestionCount(String sessionId);
+	List<String> getQuestionIds(String sessionId, User user);
+	int deleteQuestionWithAnswers(String contentId);
+	int[] deleteAllQuestionsWithAnswers(String sessionId);
+	List<String> getUnAnsweredQuestionIds(String sessionId, User user);
 	Content updateQuestion(Content content);
-	List<Content> getLectureQuestionsForUsers(Session session);
-	List<Content> getLectureQuestionsForTeachers(Session session);
-	List<Content> getFlashcardsForUsers(Session session);
-	List<Content> getFlashcardsForTeachers(Session session);
-	List<Content> getPreparationQuestionsForUsers(Session session);
-	List<Content> getPreparationQuestionsForTeachers(Session session);
-	List<Content> getAllSkillQuestions(Session session);
-	int getLectureQuestionCount(Session session);
-	int getFlashcardCount(Session session);
-	int getPreparationQuestionCount(Session session);
-	void publishQuestions(Session session, boolean publish, List<Content> contents);
-	List<Content> publishAllQuestions(Session session, boolean publish);
-	List<String> getQuestionIdsBySubject(Session session, String questionVariant, String subject);
-	List<Content> getQuestionsByIds(List<String> ids, Session session);
-	void resetQuestionsRoundState(Session session, List<Content> contents);
-	void setVotingAdmissions(Session session, boolean disableVoting, List<Content> contents);
-	List<Content> setVotingAdmissionForAllQuestions(Session session, boolean disableVoting);
-	int[] deleteAllLectureQuestionsWithAnswers(Session session);
-	int[] deleteAllFlashcardsWithAnswers(Session session);
-	int[] deleteAllPreparationQuestionsWithAnswers(Session session);
-	List<String> getSubjects(Session session, String questionVariant);
-	List<String> getUnAnsweredLectureQuestionIds(Session session, User user);
-	List<String> getUnAnsweredPreparationQuestionIds(Session session, User user);
+	List<Content> getLectureQuestionsForUsers(String sessionId);
+	List<Content> getLectureQuestionsForTeachers(String sessionId);
+	List<Content> getFlashcardsForUsers(String sessionId);
+	List<Content> getFlashcardsForTeachers(String sessionId);
+	List<Content> getPreparationQuestionsForUsers(String sessionId);
+	List<Content> getPreparationQuestionsForTeachers(String sessionId);
+	List<Content> getAllSkillQuestions(String sessionId);
+	int getLectureQuestionCount(String sessionId);
+	int getFlashcardCount(String sessionId);
+	int getPreparationQuestionCount(String sessionId);
+	void publishQuestions(String sessionId, boolean publish, List<Content> contents);
+	List<Content> publishAllQuestions(String sessionId, boolean publish);
+	List<String> getQuestionIdsBySubject(String sessionId, String questionVariant, String subject);
+	List<Content> getQuestionsByIds(List<String> ids);
+	void resetQuestionsRoundState(String sessionId, List<Content> contents);
+	void setVotingAdmissions(String sessionId, boolean disableVoting, List<Content> contents);
+	List<Content> setVotingAdmissionForAllQuestions(String sessionId, boolean disableVoting);
+	int[] deleteAllLectureQuestionsWithAnswers(String sessionId);
+	int[] deleteAllFlashcardsWithAnswers(String sessionId);
+	int[] deleteAllPreparationQuestionsWithAnswers(String sessionId);
+	List<String> getSubjects(String sessionId, String questionVariant);
+	List<String> getUnAnsweredLectureQuestionIds(String sessionId, User user);
+	List<String> getUnAnsweredPreparationQuestionIds(String sessionId, User user);
 }
diff --git a/src/main/java/de/thm/arsnova/persistance/LogEntryRepository.java b/src/main/java/de/thm/arsnova/persistance/LogEntryRepository.java
index 7ec30eb51..de88f3bd5 100644
--- a/src/main/java/de/thm/arsnova/persistance/LogEntryRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/LogEntryRepository.java
@@ -41,7 +41,7 @@ public interface LogEntryRepository {
 	 * @param payload arbitrary logging data
 	 * @param level severity of the event
 	 */
-	default void log(String event, Map<String, Object> payload, LogEntry.LogLevel level) {
+	default void log(final String event, final Map<String, Object> payload, final LogEntry.LogLevel level) {
 		create(event, level, payload);
 	}
 
@@ -53,7 +53,7 @@ public interface LogEntryRepository {
 	 * @param event type of the event
 	 * @param payload arbitrary logging data
 	 */
-	default void log(String event, Map<String, Object> payload) {
+	default void log(final String event, final Map<String, Object> payload) {
 		create(event, LogEntry.LogLevel.INFO, payload);
 	}
 
@@ -65,7 +65,7 @@ public interface LogEntryRepository {
 	 * @param level severity of the event
 	 * @param rawPayload key/value pairs of arbitrary logging data
 	 */
-	default void log(String event, LogEntry.LogLevel level, Object... rawPayload) {
+	default void log(final String event, final LogEntry.LogLevel level, final Object... rawPayload) {
 		if (rawPayload.length % 2 != 0) {
 			throw new IllegalArgumentException("");
 		}
@@ -84,7 +84,7 @@ public interface LogEntryRepository {
 	 * @param event type of the event
 	 * @param rawPayload key/value pairs of arbitrary logging data
 	 */
-	default void log(String event, Object... rawPayload) {
+	default void log(final String event, final Object... rawPayload) {
 		log(event, LogEntry.LogLevel.INFO, rawPayload);
 	}
 }
diff --git a/src/main/java/de/thm/arsnova/persistance/MotdListRepository.java b/src/main/java/de/thm/arsnova/persistance/MotdListRepository.java
index a044fe7ed..fb3d3f131 100644
--- a/src/main/java/de/thm/arsnova/persistance/MotdListRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/MotdListRepository.java
@@ -3,6 +3,6 @@ package de.thm.arsnova.persistance;
 import de.thm.arsnova.entities.MotdList;
 
 public interface MotdListRepository {
-	MotdList getMotdListForUser(final String username);
+	MotdList getMotdListForUser(String username);
 	MotdList createOrUpdateMotdList(MotdList motdlist);
 }
diff --git a/src/main/java/de/thm/arsnova/persistance/MotdRepository.java b/src/main/java/de/thm/arsnova/persistance/MotdRepository.java
index 9c783165d..1c3714698 100644
--- a/src/main/java/de/thm/arsnova/persistance/MotdRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/MotdRepository.java
@@ -27,7 +27,7 @@ public interface MotdRepository {
 	List<Motd> getMotdsForLoggedIn();
 	List<Motd> getMotdsForTutors();
 	List<Motd> getMotdsForStudents();
-	List<Motd> getMotdsForSession(final String sessionkey);
+	List<Motd> getMotdsForSession(String sessionkey);
 	Motd getMotdByKey(String key);
 	Motd createOrUpdateMotd(Motd motd);
 	boolean deleteMotd(Motd motd);
diff --git a/src/main/java/de/thm/arsnova/persistance/SessionRepository.java b/src/main/java/de/thm/arsnova/persistance/SessionRepository.java
index 4c57f8484..a248b2ab4 100644
--- a/src/main/java/de/thm/arsnova/persistance/SessionRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/SessionRepository.java
@@ -41,19 +41,19 @@ public interface SessionRepository {
 
 	Session changeSessionCreator(Session session, String newCreator);
 	int[] deleteInactiveGuestSessions(long lastActivityBefore);
-	List<Session> getMySessions(User user, final int start, final int limit);
-	List<Session> getSessionsForUsername(String username, final int start, final int limit);
+	List<Session> getMySessions(User user, int start, int limit);
+	List<Session> getSessionsForUsername(String username, int start, int limit);
 	List<Session> getPublicPoolSessions();
 	List<Session> getMyPublicPoolSessions(User user);
 	boolean sessionKeyAvailable(String keyword);
 	Session updateSessionOwnerActivity(Session session);
-	List<Session> getVisitedSessionsForUsername(String username, final int start, final int limit);
-	List<SessionInfo> getMySessionsInfo(User user, final int start, final int limit);
+	List<Session> getVisitedSessionsForUsername(String username, int start, int limit);
+	List<SessionInfo> getMySessionsInfo(User user, int start, int limit);
 	List<SessionInfo> getPublicPoolSessionsInfo();
-	List<SessionInfo> getMyPublicPoolSessionsInfo(final User user);
-	List<SessionInfo> getMyVisitedSessionsInfo(User currentUser, final int start, final int limit);
+	List<SessionInfo> getMyPublicPoolSessionsInfo(User user);
+	List<SessionInfo> getMyVisitedSessionsInfo(User currentUser, int start, int limit);
 	List<Session> getCourseSessions(List<Course> courses);
 	SessionInfo importSession(User user, ImportExportSession importSession);
 	ImportExportSession exportSession(String sessionkey, Boolean withAnswer, Boolean withFeedbackQuestions);
-	LoggedIn registerAsOnlineUser(final User user, final Session session);
+	LoggedIn registerAsOnlineUser(User user, Session session);
 }
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java
index 244290982..673767d4f 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbAnswerRepository.java
@@ -25,7 +25,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.context.ApplicationEventPublisher;
 import org.springframework.context.ApplicationEventPublisherAware;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -34,6 +33,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.stream.Collectors;
 
 public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> implements AnswerRepository, ApplicationEventPublisherAware {
 	private static final int BULK_PARTITION_SIZE = 500;
@@ -52,7 +52,7 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 
 	private ApplicationEventPublisher publisher;
 
-	public CouchDbAnswerRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbAnswerRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(Answer.class, db, createIfNotExists);
 	}
 
@@ -78,32 +78,32 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 			for (AnswerQueueElement e : elements) {
 				this.publisher.publishEvent(new NewAnswerEvent(this, e.getSession(), e.getAnswer(), e.getUser(), e.getQuestion()));
 			}
-		} catch (DbAccessException e) {
+		} catch (final DbAccessException e) {
 			logger.error("Could not bulk save answers from queue.", e);
 		}
 	}
 
 	@Override
-	public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
+	public void setApplicationEventPublisher(final ApplicationEventPublisher publisher) {
 		this.publisher = publisher;
 	}
 
 	@CacheEvict("answers")
 	@Override
-	public int deleteAnswers(final Content content) {
+	public int deleteAnswers(final String contentId) {
 		try {
 			final ViewResult result = db.queryView(createQuery("by_questionid")
-					.key(content.getId()));
+					.key(contentId));
 			final List<List<ViewResult.Row>> partitions = Lists.partition(result.getRows(), BULK_PARTITION_SIZE);
 
 			int count = 0;
-			for (List<ViewResult.Row> partition: partitions) {
-				List<BulkDeleteDocument> answersToDelete = new ArrayList<>();
+			for (final List<ViewResult.Row> partition: partitions) {
+				final List<BulkDeleteDocument> answersToDelete = new ArrayList<>();
 				for (final ViewResult.Row a : partition) {
 					final BulkDeleteDocument d = new BulkDeleteDocument(a.getId(), a.getValueAsNode().get("_rev").asText());
 					answersToDelete.add(d);
 				}
-				List<DocumentOperationResult> errors = db.executeBulk(answersToDelete);
+				final List<DocumentOperationResult> errors = db.executeBulk(answersToDelete);
 				count += partition.size() - errors.size();
 				if (errors.size() > 0) {
 					logger.error("Could not bulk delete {} of {} answers.", errors.size(), partition.size());
@@ -113,29 +113,29 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 
 			return count;
 		} catch (final DbAccessException e) {
-			logger.error("Could not delete answers for content {}.", content.getId(), e);
+			logger.error("Could not delete answers for content {}.", contentId, e);
 		}
 
 		return 0;
 	}
 
 	@Override
-	public Answer getMyAnswer(final User me, final String questionId, final int piRound) {
+	public Answer getMyAnswer(final User me, final String contentId, final int piRound) {
 		final List<Answer> answerList = queryView("by_questionid_user_piround",
-				ComplexKey.of(questionId, me.getUsername(), piRound));
+				ComplexKey.of(contentId, me.getUsername(), piRound));
 		return answerList.isEmpty() ? null : answerList.get(0);
 	}
 
 	@Override
-	public List<Answer> getAnswers(final Content content, final int piRound) {
-		final String questionId = content.getId();
+	public List<Answer> getAnswers(final String contentId, final int piRound) {
+		final String questionId = contentId;
 		final ViewResult result = db.queryView(createQuery("by_questionid_piround_text_subject")
 						.group(true)
 						.startKey(ComplexKey.of(questionId, piRound))
 						.endKey(ComplexKey.of(questionId, piRound, ComplexKey.emptyObject())));
 		final int abstentionCount = getAbstentionAnswerCount(questionId);
 
-		List<Answer> answers = new ArrayList<>();
+		final List<Answer> answers = new ArrayList<>();
 		for (final ViewResult.Row d : result) {
 			final Answer a = new Answer();
 			a.setAnswerCount(d.getValueAsInt());
@@ -151,13 +151,12 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 	}
 
 	@Override
-	public List<Answer> getAllAnswers(final Content content) {
-		final String questionId = content.getId();
+	public List<Answer> getAllAnswers(final String contentId) {
 		final ViewResult result = db.queryView(createQuery("by_questionid_piround_text_subject")
 				.group(true)
-				.startKey(ComplexKey.of(questionId))
-				.endKey(ComplexKey.of(questionId, ComplexKey.emptyObject())));
-		final int abstentionCount = getAbstentionAnswerCount(questionId);
+				.startKey(ComplexKey.of(contentId))
+				.endKey(ComplexKey.of(contentId, ComplexKey.emptyObject())));
+		final int abstentionCount = getAbstentionAnswerCount(contentId);
 
 		final List<Answer> answers = new ArrayList<>();
 		for (final ViewResult.Row d : result.getRows()) {
@@ -177,44 +176,38 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 		return answers;
 	}
 
-	@Cacheable("answers")
-	@Override
-	public List<Answer> getAnswers(final Content content) {
-		return this.getAnswers(content, content.getPiRound());
-	}
-
 	@Override
-	public int getAbstentionAnswerCount(final String questionId) {
+	public int getAbstentionAnswerCount(final String contentId) {
 		final ViewResult result = db.queryView(createQuery("by_questionid_piround_text_subject")
 				//.group(true)
-				.startKey(ComplexKey.of(questionId))
-				.endKey(ComplexKey.of(questionId, ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(contentId))
+				.endKey(ComplexKey.of(contentId, ComplexKey.emptyObject())));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
 
 	@Override
-	public int getAnswerCount(final Content content, final int piRound) {
+	public int getAnswerCount(final String contentId, final int round) {
 		final ViewResult result = db.queryView(createQuery("by_questionid_piround_text_subject")
 				//.group(true)
-				.startKey(ComplexKey.of(content.getId(), piRound))
-				.endKey(ComplexKey.of(content.getId(), piRound, ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(contentId, round))
+				.endKey(ComplexKey.of(contentId, round, ComplexKey.emptyObject())));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
 
 	@Override
-	public int getTotalAnswerCountByQuestion(final Content content) {
+	public int getTotalAnswerCountByQuestion(final String contentId) {
 		final ViewResult result = db.queryView(createQuery("by_questionid_piround_text_subject")
 				//.group(true)
-				.startKey(ComplexKey.of(content.getId()))
-				.endKey(ComplexKey.of(content.getId(), ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(contentId))
+				.endKey(ComplexKey.of(contentId, ComplexKey.emptyObject())));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
 
 	@Override
-	public List<Answer> getFreetextAnswers(final String questionId, final int start, final int limit) {
+	public List<Answer> getFreetextAnswers(final String contentId, final int start, final int limit) {
 		final int qSkip = start > 0 ? start : -1;
 		final int qLimit = limit > 0 ? limit : -1;
 
@@ -222,8 +215,8 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 						.skip(qSkip)
 						.limit(qLimit)
 						//.includeDocs(true)
-						.startKey(ComplexKey.of(questionId))
-						.endKey(ComplexKey.of(questionId, ComplexKey.emptyObject()))
+						.startKey(ComplexKey.of(contentId))
+						.endKey(ComplexKey.of(contentId, ComplexKey.emptyObject()))
 						.descending(true),
 				Answer.class);
 
@@ -231,8 +224,8 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 	}
 
 	@Override
-	public List<Answer> getMyAnswers(final User me, final Session s) {
-		return queryView("by_user_sessionid", ComplexKey.of(me.getUsername(), s.getId()));
+	public List<Answer> getMyAnswers(final User user, final String sessionId) {
+		return queryView("by_user_sessionid", ComplexKey.of(user.getUsername(), sessionId));
 	}
 
 	@Override
@@ -283,18 +276,18 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 	}
 
 	@Override
-	public int countLectureQuestionAnswers(final Session session) {
-		return countQuestionVariantAnswers(session, "lecture");
+	public int countLectureQuestionAnswers(final String sessionId) {
+		return countQuestionVariantAnswers(sessionId, "lecture");
 	}
 
 	@Override
-	public int countPreparationQuestionAnswers(final Session session) {
-		return countQuestionVariantAnswers(session, "preparation");
+	public int countPreparationQuestionAnswers(final String sessionId) {
+		return countQuestionVariantAnswers(sessionId, "preparation");
 	}
 
-	private int countQuestionVariantAnswers(final Session session, final String variant) {
+	private int countQuestionVariantAnswers(final String sessionId, final String variant) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant")
-				.key(ComplexKey.of(session.getId(), variant)));
+				.key(ComplexKey.of(sessionId, variant)));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
@@ -302,60 +295,60 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 	/* TODO: Only evict cache entry for the answer's question. This requires some refactoring. */
 	@CacheEvict(value = "answers", allEntries = true)
 	@Override
-	public int deleteAllQuestionsAnswers(final Session session) {
-		final List<Content> contents = contentRepository.getQuestions(session.getId());
-		contentRepository.resetQuestionsRoundState(session, contents);
+	public int deleteAllQuestionsAnswers(final String sessionId) {
+		final List<Content> contents = contentRepository.getQuestions(sessionId);
+		contentRepository.resetQuestionsRoundState(sessionId, contents);
+		final List<String> contentIds = contents.stream().map(Content::getId).collect(Collectors.toList());
 
-		return deleteAllAnswersForQuestions(contents);
+		return deleteAllAnswersForQuestions(contentIds);
 	}
 
 	/* TODO: Only evict cache entry for the answer's question. This requires some refactoring. */
 	@CacheEvict(value = "answers", allEntries = true)
 	@Override
-	public int deleteAllPreparationAnswers(final Session session) {
-		final List<Content> contents = contentRepository.getQuestions(session.getId(), "preparation");
-		contentRepository.resetQuestionsRoundState(session, contents);
+	public int deleteAllPreparationAnswers(final String sessionId) {
+		final List<Content> contents = contentRepository.getQuestions(sessionId, "preparation");
+		contentRepository.resetQuestionsRoundState(sessionId, contents);
+		final List<String> contentIds = contents.stream().map(Content::getId).collect(Collectors.toList());
 
-		return deleteAllAnswersForQuestions(contents);
+		return deleteAllAnswersForQuestions(contentIds);
 	}
 
 	/* TODO: Only evict cache entry for the answer's question. This requires some refactoring. */
 	@CacheEvict(value = "answers", allEntries = true)
 	@Override
-	public int deleteAllLectureAnswers(final Session session) {
-		final List<Content> contents = contentRepository.getQuestions(session.getId(), "lecture");
-		contentRepository.resetQuestionsRoundState(session, contents);
+	public int deleteAllLectureAnswers(final String sessionId) {
+		final List<Content> contents = contentRepository.getQuestions(sessionId, "lecture");
+		contentRepository.resetQuestionsRoundState(sessionId, contents);
+		final List<String> contentIds = contents.stream().map(Content::getId).collect(Collectors.toList());
 
-		return deleteAllAnswersForQuestions(contents);
+		return deleteAllAnswersForQuestions(contentIds);
 	}
 
-	public int deleteAllAnswersForQuestions(List<Content> contents) {
-		List<String> questionIds = new ArrayList<>();
-		for (Content q : contents) {
-			questionIds.add(q.getId());
-		}
+	public int deleteAllAnswersForQuestions(final List<String> contentIds) {
 		final ViewResult result = db.queryView(createQuery("by_questionid")
-				.keys(questionIds));
+				.keys(contentIds));
 		final List<BulkDeleteDocument> allAnswers = new ArrayList<>();
-		for (ViewResult.Row a : result.getRows()) {
+		for (final ViewResult.Row a : result.getRows()) {
 			final BulkDeleteDocument d = new BulkDeleteDocument(a.getId(), a.getValueAsNode().get("_rev").asText());
 			allAnswers.add(d);
 		}
 		try {
-			List<DocumentOperationResult> errors = db.executeBulk(allAnswers);
+			final List<DocumentOperationResult> errors = db.executeBulk(allAnswers);
 
 			return allAnswers.size() - errors.size();
-		} catch (DbAccessException e) {
+		} catch (final DbAccessException e) {
 			logger.error("Could not bulk delete answers.", e);
 		}
 
 		return 0;
 	}
 
-	public int[] deleteAllAnswersWithQuestions(List<Content> contents) {
+	/* TODO: Split up - the combined action should be handled on the service level. */
+	public int[] deleteAllAnswersWithQuestions(final List<Content> contents) {
 		List<String> questionIds = new ArrayList<>();
 		final List<BulkDeleteDocument> allQuestions = new ArrayList<>();
-		for (Content q : contents) {
+		for (final Content q : contents) {
 			final BulkDeleteDocument d = new BulkDeleteDocument(q.getId(), q.getRevision());
 			questionIds.add(q.getId());
 			allQuestions.add(d);
@@ -364,19 +357,19 @@ public class CouchDbAnswerRepository extends CouchDbRepositorySupport<Answer> im
 		final ViewResult result = db.queryView(createQuery("by_questionid")
 				.key(questionIds));
 		final List<BulkDeleteDocument> allAnswers = new ArrayList<>();
-		for (ViewResult.Row a : result.getRows()) {
+		for (final ViewResult.Row a : result.getRows()) {
 			final BulkDeleteDocument d = new BulkDeleteDocument(a.getId(), a.getValueAsNode().get("_rev").asText());
 			allAnswers.add(d);
 		}
 
 		try {
-			List<BulkDeleteDocument> deleteList = new ArrayList<>(allAnswers);
+			final List<BulkDeleteDocument> deleteList = new ArrayList<>(allAnswers);
 			deleteList.addAll(allQuestions);
-			List<DocumentOperationResult> errors = db.executeBulk(deleteList);
+			final List<DocumentOperationResult> errors = db.executeBulk(deleteList);
 
 			/* TODO: subtract errors from count */
 			return new int[] {allQuestions.size(), allAnswers.size()};
-		} catch (DbAccessException e) {
+		} catch (final DbAccessException e) {
 			logger.error("Could not bulk delete contents and answers.", e);
 		}
 
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbCommentRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbCommentRepository.java
index fbd64dd2a..92ac64fea 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbCommentRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbCommentRepository.java
@@ -30,7 +30,7 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 	@Autowired
 	private SessionRepository sessionRepository;
 
-	public CouchDbCommentRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbCommentRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(Comment.class, db, createIfNotExists);
 	}
 
@@ -50,19 +50,19 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 	}
 
 	@Override
-	public CommentReadingCount getInterposedReadingCount(final Session session) {
+	public CommentReadingCount getInterposedReadingCount(final String sessionId) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_read")
-				.startKey(ComplexKey.of(session.getId()))
-				.endKey(ComplexKey.of(session.getId(), ComplexKey.emptyObject()))
+				.startKey(ComplexKey.of(sessionId))
+				.endKey(ComplexKey.of(sessionId, ComplexKey.emptyObject()))
 				.group(true));
 		return getInterposedReadingCount(result);
 	}
 
 	@Override
-	public CommentReadingCount getInterposedReadingCount(final Session session, final User user) {
+	public CommentReadingCount getInterposedReadingCount(final String sessionId, final User user) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_creator_read")
-				.startKey(ComplexKey.of(session.getId(), user.getUsername()))
-				.endKey(ComplexKey.of(session.getId(), user.getUsername(), ComplexKey.emptyObject()))
+				.startKey(ComplexKey.of(sessionId, user.getUsername()))
+				.endKey(ComplexKey.of(sessionId, user.getUsername(), ComplexKey.emptyObject()))
 				.group(true));
 		return getInterposedReadingCount(result);
 	}
@@ -111,7 +111,7 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 	}
 
 	@Override
-	public List<Comment> getInterposedQuestions(final Session session, final int start, final int limit) {
+	public List<Comment> getInterposedQuestions(final String sessionId, final int start, final int limit) {
 		final int qSkip = start > 0 ? start : -1;
 		final int qLimit = limit > 0 ? limit : -1;
 
@@ -119,8 +119,8 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 						.skip(qSkip)
 						.limit(qLimit)
 						.descending(true)
-						.startKey(ComplexKey.of(session.getId(), ComplexKey.emptyObject()))
-						.endKey(ComplexKey.of(session.getId()))
+						.startKey(ComplexKey.of(sessionId, ComplexKey.emptyObject()))
+						.endKey(ComplexKey.of(sessionId))
 						.includeDocs(true),
 				Comment.class);
 //		for (Comment comment : comments) {
@@ -131,7 +131,7 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 	}
 
 	@Override
-	public List<Comment> getInterposedQuestions(final Session session, final User user, final int start, final int limit) {
+	public List<Comment> getInterposedQuestions(final String sessionId, final User user, final int start, final int limit) {
 		final int qSkip = start > 0 ? start : -1;
 		final int qLimit = limit > 0 ? limit : -1;
 
@@ -139,8 +139,8 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 						.skip(qSkip)
 						.limit(qLimit)
 						.descending(true)
-						.startKey(ComplexKey.of(session.getId(), user.getUsername(), ComplexKey.emptyObject()))
-						.endKey(ComplexKey.of(session.getId(), user.getUsername()))
+						.startKey(ComplexKey.of(sessionId, user.getUsername(), ComplexKey.emptyObject()))
+						.endKey(ComplexKey.of(sessionId, user.getUsername()))
 						.includeDocs(true),
 				Comment.class);
 //		for (Comment comment : comments) {
@@ -164,8 +164,9 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 	}
 
 	@Override
-	public Comment saveQuestion(final Session session, final Comment comment, User user) {
-		comment.setSessionId(session.getId());
+	public Comment saveQuestion(final String sessionId, final Comment comment, final User user) {
+		/* TODO: This should be done on the service level. */
+		comment.setSessionId(sessionId);
 		comment.setCreator(user.getUsername());
 		comment.setRead(false);
 		if (comment.getTimestamp() == 0) {
@@ -203,22 +204,22 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 	}
 
 	@Override
-	public int deleteAllInterposedQuestions(final Session session) {
-		final ViewResult result = db.queryView(createQuery("by_sessionid").key(session.getId()));
+	public int deleteAllInterposedQuestions(final String sessionId) {
+		final ViewResult result = db.queryView(createQuery("by_sessionid").key(sessionId));
 
-		return deleteAllInterposedQuestions(session, result);
+		return deleteAllInterposedQuestions(sessionId, result);
 	}
 
 	@Override
-	public int deleteAllInterposedQuestions(final Session session, final User user) {
+	public int deleteAllInterposedQuestions(final String sessionId, final User user) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_creator_read")
-				.startKey(ComplexKey.of(session.getId(), user.getUsername()))
-				.endKey(ComplexKey.of(session.getId(), user.getUsername(), ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(sessionId, user.getUsername()))
+				.endKey(ComplexKey.of(sessionId, user.getUsername(), ComplexKey.emptyObject())));
 
-		return deleteAllInterposedQuestions(session, result);
+		return deleteAllInterposedQuestions(sessionId, result);
 	}
 
-	private int deleteAllInterposedQuestions(final Session session, final ViewResult comments) {
+	private int deleteAllInterposedQuestions(final String sessionId, final ViewResult comments) {
 		if (comments.isEmpty()) {
 			return 0;
 		}
@@ -227,7 +228,7 @@ public class CouchDbCommentRepository extends CouchDbRepositorySupport<Comment>
 			try {
 				db.delete(row.getId(), row.getValueAsNode().get("rev").asText());
 			} catch (final UpdateConflictException e) {
-				logger.error("Could not delete all comments {}.", session, e);
+				logger.error("Could not delete all comments {}.", sessionId, e);
 			}
 		}
 
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbContentRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbContentRepository.java
index fca13b13e..2062894b7 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbContentRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbContentRepository.java
@@ -1,7 +1,6 @@
 package de.thm.arsnova.persistance.couchdb;
 
 import de.thm.arsnova.entities.Content;
-import de.thm.arsnova.entities.Session;
 import de.thm.arsnova.entities.User;
 import de.thm.arsnova.persistance.AnswerRepository;
 import de.thm.arsnova.persistance.ContentRepository;
@@ -39,17 +38,17 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	@Autowired
 	private AnswerRepository answerRepository;
 
-	public CouchDbContentRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbContentRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(Content.class, db, createIfNotExists);
 	}
 
 	@Cacheable("skillquestions")
 	@Override
-	public List<Content> getSkillQuestionsForUsers(final Session session) {
+	public List<Content> getSkillQuestionsForUsers(final String sessionId) {
 		final List<Content> contents = new ArrayList<>();
-		final List<Content> questions1 = getQuestions(session.getId(), "lecture", true);
-		final List<Content> questions2 = getQuestions(session.getId(), "preparation", true);
-		final List<Content> questions3 = getQuestions(session.getId(), "flashcard", true);
+		final List<Content> questions1 = getQuestions(sessionId, "lecture", true);
+		final List<Content> questions2 = getQuestions(sessionId, "preparation", true);
+		final List<Content> questions3 = getQuestions(sessionId, "flashcard", true);
 		contents.addAll(questions1);
 		contents.addAll(questions2);
 		contents.addAll(questions3);
@@ -59,27 +58,28 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 
 	@Cacheable("skillquestions")
 	@Override
-	public List<Content> getSkillQuestionsForTeachers(final Session session) {
-		return getQuestions(new Object[] {session.getId()}, session);
+	public List<Content> getSkillQuestionsForTeachers(final String sessionId) {
+		return getQuestions(new Object[] {sessionId}, sessionId);
 	}
 
 	@Override
-	public int getSkillQuestionCount(final Session session) {
+	public int getSkillQuestionCount(final String sessionId) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId()))
-				.endKey(ComplexKey.of(session.getId(), ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(sessionId))
+				.endKey(ComplexKey.of(sessionId, ComplexKey.emptyObject())));
 
 		return result.getSize();
 	}
 
-	@Caching(evict = {@CacheEvict(value = "skillquestions", key = "#session"),
-			@CacheEvict(value = "lecturequestions", key = "#session", condition = "#content.getQuestionVariant().equals('lecture')"),
-			@CacheEvict(value = "preparationquestions", key = "#session", condition = "#content.getQuestionVariant().equals('preparation')"),
-			@CacheEvict(value = "flashcardquestions", key = "#session", condition = "#content.getQuestionVariant().equals('flashcard')") },
+	@Caching(evict = {@CacheEvict(value = "skillquestions", key = "#sessionId"),
+			@CacheEvict(value = "lecturequestions", key = "#sessionId", condition = "#content.getQuestionVariant().equals('lecture')"),
+			@CacheEvict(value = "preparationquestions", key = "#sessionId", condition = "#content.getQuestionVariant().equals('preparation')"),
+			@CacheEvict(value = "flashcardquestions", key = "#sessionId", condition = "#content.getQuestionVariant().equals('flashcard')") },
 			put = {@CachePut(value = "questions", key = "#content.id")})
 	@Override
-	public Content saveQuestion(final Session session, final Content content) {
-		content.setSessionId(session.getId());
+	public Content saveQuestion(final String sessionId, final Content content) {
+		/* TODO: This should be done on the service level. */
+		content.setSessionId(sessionId);
 		try {
 			db.create(content);
 
@@ -100,7 +100,8 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	@Override
 	public Content updateQuestion(final Content content) {
 		try {
-			/* TODO: Make sure that sessionId is valid before so the content does not need to be retrieved. */
+			/* TODO: This should be done on the service level. Make sure that
+			 * sessionId is valid before so the content does not need to be retrieved. */
 			final Content oldContent = get(content.getId());
 			content.setId(oldContent.getId());
 			content.setRevision(oldContent.getRevision());
@@ -132,8 +133,8 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	}
 
 	@Override
-	public List<String> getQuestionIds(final Session session, final User user) {
-		return collectQuestionIds(db.queryView(createQuery("by_sessionid_variant_active").key(session.getId())));
+	public List<String> getQuestionIds(final String sessionId, final User user) {
+		return collectQuestionIds(db.queryView(createQuery("by_sessionid_variant_active").key(sessionId)));
 	}
 
 	/* TODO: Only evict cache entry for the content's session. This requires some refactoring. */
@@ -143,30 +144,30 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 			@CacheEvict(value = "preparationquestions", allEntries = true, condition = "#content.getQuestionVariant().equals('preparation')"),
 			@CacheEvict(value = "flashcardquestions", allEntries = true, condition = "#content.getQuestionVariant().equals('flashcard')") })
 	@Override
-	public int deleteQuestionWithAnswers(final Content content) {
+	public int deleteQuestionWithAnswers(final String contentId) {
 		try {
-			int count = answerRepository.deleteAnswers(content);
-			db.delete(content);
+			final int count = answerRepository.deleteAnswers(contentId);
+			db.delete(contentId);
 			dbLogger.log("delete", "type", "content", "answerCount", count);
 
 			return count;
 		} catch (final IllegalArgumentException e) {
-			logger.error("Could not delete content {}.", content.getId(), e);
+			logger.error("Could not delete content {}.", contentId, e);
 		}
 
 		return 0;
 	}
 
 	@Caching(evict = { @CacheEvict(value = "questions", allEntries = true),
-			@CacheEvict(value = "skillquestions", key = "#session"),
-			@CacheEvict(value = "lecturequestions", key = "#session"),
-			@CacheEvict(value = "preparationquestions", key = "#session"),
-			@CacheEvict(value = "flashcardquestions", key = "#session") })
+			@CacheEvict(value = "skillquestions", key = "#sessionId"),
+			@CacheEvict(value = "lecturequestions", key = "#sessionId"),
+			@CacheEvict(value = "preparationquestions", key = "#sessionId"),
+			@CacheEvict(value = "flashcardquestions", key = "#sessionId") })
 	@Override
-	public int[] deleteAllQuestionsWithAnswers(final Session session) {
+	public int[] deleteAllQuestionsWithAnswers(final String sessionId) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId()))
-				.endKey(ComplexKey.of(session.getId(), ComplexKey.emptyObject()))
+				.startKey(ComplexKey.of(sessionId))
+				.endKey(ComplexKey.of(sessionId, ComplexKey.emptyObject()))
 				.reduce(false));
 
 		return deleteAllQuestionDocumentsWithAnswers(result);
@@ -181,7 +182,7 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 			contents.add(q);
 		}
 
-		int[] count = answerRepository.deleteAllAnswersWithQuestions(contents);
+		final int[] count = answerRepository.deleteAllAnswersWithQuestions(contents);
 		dbLogger.log("delete", "type", "question", "questionCount", count[0]);
 		dbLogger.log("delete", "type", "answer", "answerCount", count[1]);
 
@@ -189,85 +190,85 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	}
 
 	@Override
-	public List<String> getUnAnsweredQuestionIds(final Session session, final User user) {
+	public List<String> getUnAnsweredQuestionIds(final String sessionId, final User user) {
 		final ViewResult result = db.queryView(createQuery("questionid_by_user_sessionid_variant")
 				.designDocId("_design/Answer")
-				.startKey(ComplexKey.of(user.getUsername(), session.getId()))
-				.endKey(ComplexKey.of(user.getUsername(), session.getId(), ComplexKey.emptyObject())));
-		List<String> answeredIds = new ArrayList<>();
-		for (ViewResult.Row row : result.getRows()) {
+				.startKey(ComplexKey.of(user.getUsername(), sessionId))
+				.endKey(ComplexKey.of(user.getUsername(), sessionId, ComplexKey.emptyObject())));
+		final List<String> answeredIds = new ArrayList<>();
+		for (final ViewResult.Row row : result.getRows()) {
 			answeredIds.add(row.getId());
 		}
-		return collectUnansweredQuestionIds(getQuestionIds(session, user), answeredIds);
+		return collectUnansweredQuestionIds(getQuestionIds(sessionId, user), answeredIds);
 	}
 
 	@Override
-	public List<String> getUnAnsweredLectureQuestionIds(final Session session, final User user) {
+	public List<String> getUnAnsweredLectureQuestionIds(final String sessionId, final User user) {
 		final ViewResult result = db.queryView(createQuery("questionid_piround_by_user_sessionid_variant")
 				.designDocId("_design/Answer")
-				.key(ComplexKey.of(user.getUsername(), session.getId(), "lecture")));
-		Map<String, Integer> answeredQuestions = new HashMap<>();
-		for (ViewResult.Row row : result.getRows()) {
+				.key(ComplexKey.of(user.getUsername(), sessionId, "lecture")));
+		final Map<String, Integer> answeredQuestions = new HashMap<>();
+		for (final ViewResult.Row row : result.getRows()) {
 			answeredQuestions.put(row.getId(), row.getKeyAsNode().get(2).asInt());
 		}
 
-		return collectUnansweredQuestionIdsByPiRound(getLectureQuestionsForUsers(session), answeredQuestions);
+		return collectUnansweredQuestionIdsByPiRound(getLectureQuestionsForUsers(sessionId), answeredQuestions);
 	}
 
 	@Override
-	public List<String> getUnAnsweredPreparationQuestionIds(final Session session, final User user) {
+	public List<String> getUnAnsweredPreparationQuestionIds(final String sessionId, final User user) {
 		final ViewResult result = db.queryView(createQuery("questionid_piround_by_user_sessionid_variant")
 				.designDocId("_design/Answer")
-				.key(ComplexKey.of(user.getUsername(), session.getId(), "preparation")));
-		Map<String, Integer> answeredQuestions = new HashMap<>();
-		for (ViewResult.Row row : result.getRows()) {
+				.key(ComplexKey.of(user.getUsername(), sessionId, "preparation")));
+		final Map<String, Integer> answeredQuestions = new HashMap<>();
+		for (final ViewResult.Row row : result.getRows()) {
 			answeredQuestions.put(row.getId(), row.getKeyAsNode().get(2).asInt());
 		}
 
-		return collectUnansweredQuestionIdsByPiRound(getPreparationQuestionsForUsers(session), answeredQuestions);
+		return collectUnansweredQuestionIdsByPiRound(getPreparationQuestionsForUsers(sessionId), answeredQuestions);
 	}
 
 	@Cacheable("lecturequestions")
 	@Override
-	public List<Content> getLectureQuestionsForUsers(final Session session) {
-		return getQuestions(session.getId(), "lecture", true);
+	public List<Content> getLectureQuestionsForUsers(final String sessionId) {
+		return getQuestions(sessionId, "lecture", true);
 	}
 
 	@Override
-	public List<Content> getLectureQuestionsForTeachers(final Session session) {
-		return getQuestions(session.getId(), "lecture");
+	public List<Content> getLectureQuestionsForTeachers(final String sessionId) {
+		return getQuestions(sessionId, "lecture");
 	}
 
 	@Cacheable("flashcardquestions")
 	@Override
-	public List<Content> getFlashcardsForUsers(final Session session) {
-		return getQuestions(session.getId(), "flashcard", true);
+	public List<Content> getFlashcardsForUsers(final String sessionId) {
+		return getQuestions(sessionId, "flashcard", true);
 	}
 
 	@Override
-	public List<Content> getFlashcardsForTeachers(final Session session) {
-		return getQuestions(session.getId(), "flashcard");
+	public List<Content> getFlashcardsForTeachers(final String sessionId) {
+		return getQuestions(sessionId, "flashcard");
 	}
 
 	@Cacheable("preparationquestions")
 	@Override
-	public List<Content> getPreparationQuestionsForUsers(final Session session) {
-		return getQuestions(session.getId(), "preparation", true);
+	public List<Content> getPreparationQuestionsForUsers(final String sessionId) {
+		return getQuestions(sessionId, "preparation", true);
 	}
 
 	@Override
-	public List<Content> getPreparationQuestionsForTeachers(final Session session) {
-		return getQuestions(session.getId(), "preparation");
+	public List<Content> getPreparationQuestionsForTeachers(final String sessionId) {
+		return getQuestions(sessionId, "preparation");
 	}
 
 	@Override
-	public List<Content> getAllSkillQuestions(final Session session) {
-		return getQuestions(session.getId());
+	public List<Content> getAllSkillQuestions(final String sessionId) {
+		return getQuestions(sessionId);
 	}
 
 	@Override
 	public List<Content> getQuestions(final Object... keys) {
-		Object[] endKeys = Arrays.copyOf(keys, keys.length + 1);
+		final Object[] endKeys = Arrays.copyOf(keys, keys.length + 1);
 		endKeys[keys.length] = ComplexKey.emptyObject();
 		final List<Content> contents = db.queryView(createQuery("by_sessionid_variant_active")
 						.includeDocs(true)
@@ -275,7 +276,7 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 						.startKey(ComplexKey.of(keys))
 						.endKey(ComplexKey.of(endKeys)),
 				Content.class);
-		for (Content content : contents) {
+		for (final Content content : contents) {
 			content.updateRoundManagementState();
 			//content.setSessionKeyword(session.getKeyword());
 		}
@@ -284,31 +285,31 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	}
 
 	@Override
-	public int getLectureQuestionCount(final Session session) {
+	public int getLectureQuestionCount(final String sessionId) {
 		/* TODO: reduce code duplication */
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), "lecture"))
-				.endKey(ComplexKey.of(session.getId(), "lecture", ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(sessionId, "lecture"))
+				.endKey(ComplexKey.of(sessionId, "lecture", ComplexKey.emptyObject())));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
 
 	@Override
-	public int getFlashcardCount(final Session session) {
+	public int getFlashcardCount(final String sessionId) {
 		/* TODO: reduce code duplication */
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), "flashcard"))
-				.endKey(ComplexKey.of(session.getId(), "flashcard", ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(sessionId, "flashcard"))
+				.endKey(ComplexKey.of(sessionId, "flashcard", ComplexKey.emptyObject())));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
 
 	@Override
-	public int getPreparationQuestionCount(final Session session) {
+	public int getPreparationQuestionCount(final String sessionId) {
 		/* TODO: reduce code duplication */
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), "preparation"))
-				.endKey(ComplexKey.of(session.getId(), "preparation", ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(sessionId, "preparation"))
+				.endKey(ComplexKey.of(sessionId, "preparation", ComplexKey.emptyObject())));
 
 		return result.isEmpty() ? 0 : result.getRows().get(0).getValueAsInt();
 	}
@@ -319,10 +320,10 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 			@CacheEvict("lecturequestions"),
 			@CacheEvict(value = "answers", allEntries = true)})
 	@Override
-	public int[] deleteAllLectureQuestionsWithAnswers(final Session session) {
+	public int[] deleteAllLectureQuestionsWithAnswers(final String sessionId) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), "lecture"))
-				.endKey(ComplexKey.of(session.getId(), "lecture", ComplexKey.emptyObject()))
+				.startKey(ComplexKey.of(sessionId, "lecture"))
+				.endKey(ComplexKey.of(sessionId, "lecture", ComplexKey.emptyObject()))
 				.reduce(false));
 
 		return deleteAllQuestionDocumentsWithAnswers(result);
@@ -334,10 +335,10 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 			@CacheEvict("flashcardquestions"),
 			@CacheEvict(value = "answers", allEntries = true)})
 	@Override
-	public int[] deleteAllFlashcardsWithAnswers(final Session session) {
+	public int[] deleteAllFlashcardsWithAnswers(final String sessionId) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), "flashcard"))
-				.endKey(ComplexKey.of(session.getId(), "flashcard", ComplexKey.emptyObject()))
+				.startKey(ComplexKey.of(sessionId, "flashcard"))
+				.endKey(ComplexKey.of(sessionId, "flashcard", ComplexKey.emptyObject()))
 				.reduce(false));
 
 		return deleteAllQuestionDocumentsWithAnswers(result);
@@ -349,23 +350,23 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 			@CacheEvict("preparationquestions"),
 			@CacheEvict(value = "answers", allEntries = true)})
 	@Override
-	public int[] deleteAllPreparationQuestionsWithAnswers(final Session session) {
+	public int[] deleteAllPreparationQuestionsWithAnswers(final String sessionId) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), "preparation"))
-				.endKey(ComplexKey.of(session.getId(), "preparation", ComplexKey.emptyObject()))
+				.startKey(ComplexKey.of(sessionId, "preparation"))
+				.endKey(ComplexKey.of(sessionId, "preparation", ComplexKey.emptyObject()))
 				.reduce(false));
 
 		return deleteAllQuestionDocumentsWithAnswers(result);
 	}
 
 	private List<String> collectUnansweredQuestionIds(
-			final List<String> questions,
-			final List<String> answeredQuestions
+			final List<String> contentIds,
+			final List<String> answeredContentIds
 	) {
 		final List<String> unanswered = new ArrayList<>();
-		for (final String questionId : questions) {
-			if (!answeredQuestions.contains(questionId)) {
-				unanswered.add(questionId);
+		for (final String contentId : contentIds) {
+			if (!answeredContentIds.contains(contentId)) {
+				unanswered.add(contentId);
 			}
 		}
 		return unanswered;
@@ -396,24 +397,24 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	}
 
 	@Override
-	public List<Content> publishAllQuestions(final Session session, final boolean publish) {
+	public List<Content> publishAllQuestions(final String sessionId, final boolean publish) {
 		final List<Content> contents = db.queryView(createQuery("by_sessionid_variant_active")
-						.startKey(ComplexKey.of(session.getId()))
-						.endKey(ComplexKey.of(session.getId(), ComplexKey.emptyObject())),
+						.startKey(ComplexKey.of(sessionId))
+						.endKey(ComplexKey.of(sessionId, ComplexKey.emptyObject())),
 				Content.class);
 		/* FIXME: caching */
-		publishQuestions(session, publish, contents);
+		publishQuestions(sessionId, publish, contents);
 
 		return contents;
 	}
 
 	@Caching(evict = { @CacheEvict(value = "contents", allEntries = true),
-			@CacheEvict(value = "skillquestions", key = "#session"),
-			@CacheEvict(value = "lecturequestions", key = "#session"),
-			@CacheEvict(value = "preparationquestions", key = "#session"),
-			@CacheEvict(value = "flashcardquestions", key = "#session") })
+			@CacheEvict(value = "skillquestions", key = "#sessionId"),
+			@CacheEvict(value = "lecturequestions", key = "#sessionId"),
+			@CacheEvict(value = "preparationquestions", key = "#sessionId"),
+			@CacheEvict(value = "flashcardquestions", key = "#sessionId") })
 	@Override
-	public void publishQuestions(final Session session, final boolean publish, List<Content> contents) {
+	public void publishQuestions(final String sessionId, final boolean publish, final List<Content> contents) {
 		for (final Content content : contents) {
 			content.setActive(publish);
 		}
@@ -425,25 +426,25 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	}
 
 	@Override
-	public List<Content> setVotingAdmissionForAllQuestions(final Session session, final boolean disableVoting) {
+	public List<Content> setVotingAdmissionForAllQuestions(final String sessionId, final boolean disableVoting) {
 		final List<Content> contents = db.queryView(createQuery("by_sessionid_variant_active")
-						.startKey(ComplexKey.of(session.getId()))
-						.endKey(ComplexKey.of(session.getId(), ComplexKey.emptyObject()))
+						.startKey(ComplexKey.of(sessionId))
+						.endKey(ComplexKey.of(sessionId, ComplexKey.emptyObject()))
 						.includeDocs(true),
 				Content.class);
 		/* FIXME: caching */
-		setVotingAdmissions(session, disableVoting, contents);
+		setVotingAdmissions(sessionId, disableVoting, contents);
 
 		return contents;
 	}
 
 	@Caching(evict = { @CacheEvict(value = "contents", allEntries = true),
-			@CacheEvict(value = "skillquestions", key = "#session"),
-			@CacheEvict(value = "lecturequestions", key = "#session"),
-			@CacheEvict(value = "preparationquestions", key = "#session"),
-			@CacheEvict(value = "flashcardquestions", key = "#session") })
+			@CacheEvict(value = "skillquestions", key = "#sessionId"),
+			@CacheEvict(value = "lecturequestions", key = "#sessionId"),
+			@CacheEvict(value = "preparationquestions", key = "#sessionId"),
+			@CacheEvict(value = "flashcardquestions", key = "#sessionId") })
 	@Override
-	public void setVotingAdmissions(final Session session, final boolean disableVoting, List<Content> contents) {
+	public void setVotingAdmissions(final String sessionId, final boolean disableVoting, final List<Content> contents) {
 		for (final Content q : contents) {
 			if (!"flashcard".equals(q.getQuestionType())) {
 				q.setVotingDisabled(disableVoting);
@@ -459,12 +460,12 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 
 	/* TODO: remove if this method is no longer used */
 	@Override
-	public List<String> getQuestionIdsBySubject(Session session, String questionVariant, String subject) {
+	public List<String> getQuestionIdsBySubject(final String sessionId, final String questionVariant, final String subject) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), questionVariant, 1, subject))
-				.endKey(ComplexKey.of(session.getId(), questionVariant, 1, subject, ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(sessionId, questionVariant, 1, subject))
+				.endKey(ComplexKey.of(sessionId, questionVariant, 1, subject, ComplexKey.emptyObject())));
 
-		List<String> qids = new ArrayList<>();
+		final List<String> qids = new ArrayList<>();
 
 		for (final ViewResult.Row row : result.getRows()) {
 			final String s = row.getId();
@@ -475,17 +476,17 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	}
 
 	@Override
-	public List<Content> getQuestionsByIds(List<String> ids, final Session session) {
+	public List<Content> getQuestionsByIds(final List<String> ids) {
 		return db.queryView(new ViewQuery().allDocs().keys(ids).includeDocs(true), Content.class);
 	}
 
 	@Override
-	public List<String> getSubjects(Session session, String questionVariant) {
+	public List<String> getSubjects(final String sessionId, final String questionVariant) {
 		final ViewResult result = db.queryView(createQuery("by_sessionid_variant_active")
-				.startKey(ComplexKey.of(session.getId(), questionVariant))
-				.endKey(ComplexKey.of(session.getId(), questionVariant, ComplexKey.emptyObject())));
+				.startKey(ComplexKey.of(sessionId, questionVariant))
+				.endKey(ComplexKey.of(sessionId, questionVariant, ComplexKey.emptyObject())));
 
-		Set<String> uniqueSubjects = new HashSet<>();
+		final Set<String> uniqueSubjects = new HashSet<>();
 
 		for (final ViewResult.Row row : result.getRows()) {
 			uniqueSubjects.add(row.getKeyAsNode().get(3).asText());
@@ -495,14 +496,14 @@ public class CouchDbContentRepository extends CouchDbRepositorySupport<Content>
 	}
 
 	@Caching(evict = { @CacheEvict(value = "contents", allEntries = true),
-			@CacheEvict(value = "skillquestions", key = "#session"),
-			@CacheEvict(value = "lecturequestions", key = "#session"),
-			@CacheEvict(value = "preparationquestions", key = "#session"),
-			@CacheEvict(value = "flashcardquestions", key = "#session") })
+			@CacheEvict(value = "skillquestions", key = "#sessionId"),
+			@CacheEvict(value = "lecturequestions", key = "#sessionId"),
+			@CacheEvict(value = "preparationquestions", key = "#sessionId"),
+			@CacheEvict(value = "flashcardquestions", key = "#sessionId") })
 	@Override
-	public void resetQuestionsRoundState(final Session session, List<Content> contents) {
+	public void resetQuestionsRoundState(final String sessionId, final List<Content> contents) {
 		for (final Content q : contents) {
-			q.setSessionId(session.getId());
+			q.setSessionId(sessionId);
 			q.resetQuestionState();
 		}
 		try {
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbLogEntryRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbLogEntryRepository.java
index 0ceaa3bf0..ff7fc21a5 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbLogEntryRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbLogEntryRepository.java
@@ -29,13 +29,13 @@ import java.util.Map;
 public class CouchDbLogEntryRepository extends CouchDbRepositorySupport<LogEntry> implements LogEntryRepository {
 	private static final Logger logger = LoggerFactory.getLogger(CouchDbLogEntryRepository.class);
 
-	public CouchDbLogEntryRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbLogEntryRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(LogEntry.class, db, createIfNotExists);
 	}
 
 	@Override
-	public void create(String event, LogEntry.LogLevel level, Map<String, Object> payload) {
-		LogEntry log = new LogEntry(event, level.ordinal(), payload);
+	public void create(final String event, final LogEntry.LogLevel level, final Map<String, Object> payload) {
+		final LogEntry log = new LogEntry(event, level.ordinal(), payload);
 		try {
 			db.create(log);
 		} catch (final IllegalArgumentException e) {
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdListRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdListRepository.java
index 4260a6668..df5800aa9 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdListRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdListRepository.java
@@ -15,20 +15,20 @@ import java.util.List;
 public class CouchDbMotdListRepository extends CouchDbRepositorySupport<MotdList> implements MotdListRepository {
 	private static final Logger logger = LoggerFactory.getLogger(CouchDbMotdListRepository.class);
 
-	public CouchDbMotdListRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbMotdListRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(MotdList.class, db, createIfNotExists);
 	}
 
 	@Override
 	@Cacheable(cacheNames = "motdlist", key = "#p0")
 	public MotdList getMotdListForUser(final String username) {
-		List<MotdList> motdListList = queryView("by_username", username);
+		final List<MotdList> motdListList = queryView("by_username", username);
 		return motdListList.isEmpty() ? new MotdList() : motdListList.get(0);
 	}
 
 	@Override
 	@CachePut(cacheNames = "motdlist", key = "#p0.username")
-	public MotdList createOrUpdateMotdList(MotdList motdlist) {
+	public MotdList createOrUpdateMotdList(final MotdList motdlist) {
 		try {
 			if (motdlist.getId() != null) {
 				update(motdlist);
@@ -37,7 +37,7 @@ public class CouchDbMotdListRepository extends CouchDbRepositorySupport<MotdList
 			}
 
 			return motdlist;
-		} catch (DbAccessException e) {
+		} catch (final DbAccessException e) {
 			logger.error("Could not save MotD list {}.", motdlist, e);
 		}
 
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java
index e3df5f055..dc5f4ee9f 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java
@@ -37,7 +37,7 @@ public class CouchDbMotdRepository extends CouchDbRepositorySupport<Motd> implem
 	@Autowired
 	private SessionService sessionService;
 
-	public CouchDbMotdRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbMotdRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(Motd.class, db, createIfNotExists);
 	}
 
@@ -84,22 +84,22 @@ public class CouchDbMotdRepository extends CouchDbRepositorySupport<Motd> implem
 		return getMotds("by_sessionkey", sessionkey);
 	}
 
-	private List<Motd> getMotds(String viewName, String key) {
+	private List<Motd> getMotds(final String viewName, final String key) {
 		return queryView(viewName, key);
 	}
 
 	@Override
-	public Motd getMotdByKey(String key) {
-		List<Motd> motd = queryView("by_motdkey", key);
+	public Motd getMotdByKey(final String key) {
+		final List<Motd> motd = queryView("by_motdkey", key);
 
 		return motd.get(0);
 	}
 
 	@Override
 	@CacheEvict(cacheNames = "motds", key = "#p0.audience.concat(#p0.sessionkey)")
-	public Motd createOrUpdateMotd(Motd motd) {
-		String id = motd.getId();
-		String rev = motd.getRevision();
+	public Motd createOrUpdateMotd(final Motd motd) {
+		final String id = motd.getId();
+		final String rev = motd.getRevision();
 
 		if (null != id) {
 			Motd oldMotd = get(id);
@@ -115,7 +115,7 @@ public class CouchDbMotdRepository extends CouchDbRepositorySupport<Motd> implem
 
 	@Override
 	@CacheEvict(cacheNames = "motds", key = "#p0.audience.concat(#p0.sessionkey)")
-	public boolean deleteMotd(Motd motd) {
+	public boolean deleteMotd(final Motd motd) {
 		return db.delete(motd) != null;
 	}
 }
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java
index 8a00fddfe..0858de683 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java
@@ -67,7 +67,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	@Autowired
 	private MotdRepository motdRepository;
 
-	public CouchDbSessionRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbSessionRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(Session.class, db, createIfNotExists);
 	}
 
@@ -138,14 +138,14 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	}
 
 	@Override
-	public List<Session> getVisitedSessionsForUsername(String username, final int start, final int limit) {
+	public List<Session> getVisitedSessionsForUsername(final String username, final int start, final int limit) {
 		final int qSkip = start > 0 ? start : -1;
 		final int qLimit = limit > 0 ? limit : -1;
 
 		try {
-			ViewResult visitedSessionResult = db.queryView(createQuery("visited_sessions_by_user")
+			final ViewResult visitedSessionResult = db.queryView(createQuery("visited_sessions_by_user")
 					.designDocId("_design/LoggedIn").key(username));
-			List<Session> visitedSessions = visitedSessionResult.getRows().stream().map(vs -> {
+			final List<Session> visitedSessions = visitedSessionResult.getRows().stream().map(vs -> {
 				final Session s = new Session();
 				s.setId(vs.getValueAsNode().get("_id").asText());
 				s.setKeyword(vs.getValueAsNode().get("keyword").asText());
@@ -178,10 +178,10 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 				return result;
 			}
 			// Update document to remove sessions that don't exist anymore
-				List<VisitedSession> newVisitedSessions = new ArrayList<>();
-				for (final Session s : result) {
-					newVisitedSessions.add(new VisitedSession(s));
-				}
+			final List<VisitedSession> newVisitedSessions = new ArrayList<>();
+			for (final Session s : result) {
+				newVisitedSessions.add(new VisitedSession(s));
+			}
 
 			try {
 				final LoggedIn loggedIn = db.get(LoggedIn.class, visitedSessionResult.getRows().get(0).getId());
@@ -192,14 +192,14 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 			}
 
 			return result;
-		} catch (DocumentNotFoundException e) {
+		} catch (final DocumentNotFoundException e) {
 			return new ArrayList<>();
 		}
 	}
 
 	@Override
 	public List<SessionInfo> getMyVisitedSessionsInfo(final User user, final int start, final int limit) {
-		List<Session> sessions = getVisitedSessionsForUsername(user.getUsername(), start, limit);
+		final List<Session> sessions = getVisitedSessionsForUsername(user.getUsername(), start, limit);
 		if (sessions.isEmpty()) {
 			return new ArrayList<>();
 		}
@@ -229,7 +229,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	@Override
 	@Caching(evict = { @CacheEvict("sessions"), @CacheEvict(cacheNames = "sessions", key = "#p0.keyword") })
 	public Session changeSessionCreator(final Session session, final String newCreator) {
-		Session s = get(session.getId());
+		final Session s = get(session.getId());
 		s.setCreator(newCreator);
 		try {
 			update(s);
@@ -245,7 +245,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	public int[] deleteSession(final Session session) {
 		/* FIXME: not yet migrated - move to service layer */
 		throw new UnsupportedOperationException();
-//		int[] count = new int[] {0, 0};
+//		final int[] count = new int[] {0, 0};
 //		try {
 //			count = deleteAllQuestionsWithAnswers(session);
 //			remove(session);
@@ -260,16 +260,16 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	}
 
 	@Override
-	public int[] deleteInactiveGuestSessions(long lastActivityBefore) {
-		ViewResult result = db.queryView(
+	public int[] deleteInactiveGuestSessions(final long lastActivityBefore) {
+		final ViewResult result = db.queryView(
 				createQuery("by_lastactivity_for_guests").endKey(lastActivityBefore));
-		int[] count = new int[3];
+		final int[] count = new int[3];
 
-		for (ViewResult.Row row : result.getRows()) {
-			Session s = new Session();
+		for (final ViewResult.Row row : result.getRows()) {
+			final Session s = new Session();
 			s.setId(row.getId());
 			s.setRevision(row.getValueAsNode().get("_rev").asText());
-			int[] qaCount = deleteSession(s);
+			final int[] qaCount = deleteSession(s);
 			count[1] += qaCount[0];
 			count[2] += qaCount[1];
 		}
@@ -284,15 +284,15 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	}
 
 	@Override
-	public SessionInfo importSession(User user, ImportExportSession importSession) {
+	public SessionInfo importSession(final User user, final ImportExportSession importSession) {
 		/* FIXME: not yet migrated - move to service layer */
 		throw new UnsupportedOperationException();
 //		final Session session = this.saveSession(user, importSession.generateSessionEntity(user));
-//		List<Document> questions = new ArrayList<>();
+//		final List<Document> questions = new ArrayList<>();
 //		// We need to remember which answers belong to which question.
 //		// The answers need a questionId, so we first store the questions to get the IDs.
 //		// Then we update the answer objects and store them as well.
-//		Map<Document, ImportExportSession.ImportExportContent> mapping = new HashMap<>();
+//		final Map<Document, ImportExportSession.ImportExportContent> mapping = new HashMap<>();
 //		// Later, generate all answer documents
 //		List<Document> answers = new ArrayList<>();
 //		// We can then push answers together with comments in one large bulk request
@@ -301,8 +301,8 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 //		List<Document> motds = new ArrayList<>();
 //		try {
 //			// add session id to all questions and generate documents
-//			for (ImportExportSession.ImportExportContent question : importSession.getQuestions()) {
-//				Document doc = toQuestionDocument(session, question);
+//			for (final ImportExportSession.ImportExportContent question : importSession.getQuestions()) {
+//				final Document doc = toQuestionDocument(session, question);
 //				question.setSessionId(session.getId());
 //				questions.add(doc);
 //				mapping.put(doc, question);
@@ -315,7 +315,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 //				final ImportExportSession.ImportExportContent question = entry.getValue();
 //				question.setId(doc.getId());
 //				question.setRevision(doc.getRev());
-//				for (de.thm.arsnova.entities.transport.Answer answer : question.getAnswers()) {
+//				for (final de.thm.arsnova.entities.transport.Answer answer : question.getAnswers()) {
 //					final Answer a = answer.generateAnswerEntity(user, question);
 //					final Document answerDoc = new Document();
 //					answerDoc.put("type", "skill_question_answer");
@@ -335,7 +335,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 //					answers.add(answerDoc);
 //				}
 //			}
-//			for (de.thm.arsnova.entities.transport.Comment i : importSession.getFeedbackQuestions()) {
+//			for (final de.thm.arsnova.entities.transport.Comment i : importSession.getFeedbackQuestions()) {
 //				final Document q = new Document();
 //				q.put("type", "interposed_question");
 //				q.put("sessionId", session.getId());
@@ -347,7 +347,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 //				q.put("creator", "");
 //				interposedQuestions.add(q);
 //			}
-//			for (Motd m : importSession.getMotds()) {
+//			for (final Motd m : importSession.getMotds()) {
 //				final Document d = new Document();
 //				d.put("type", "motd");
 //				d.put("motdkey", m.getMotdkey());
@@ -359,11 +359,11 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 //				d.put("enddate", String.valueOf(m.getEnddate().getTime()));
 //				motds.add(d);
 //			}
-//			List<Document> documents = new ArrayList<>(answers);
+//			final List<Document> documents = new ArrayList<>(answers);
 //			database.bulkSaveDocuments(interposedQuestions.toArray(new Document[interposedQuestions.size()]));
 //			database.bulkSaveDocuments(motds.toArray(new Document[motds.size()]));
 //			database.bulkSaveDocuments(documents.toArray(new Document[documents.size()]));
-//		} catch (IOException e) {
+//		} catch (final IOException e) {
 //			logger.error("Could not import session.", e);
 //			// Something went wrong, delete this session since we do not want a partial import
 //			this.deleteSession(session);
@@ -373,24 +373,27 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	}
 
 	@Override
-	public ImportExportSession exportSession(String sessionkey, Boolean withAnswers, Boolean withFeedbackQuestions) {
+	public ImportExportSession exportSession(
+			final String sessionkey,
+			final Boolean withAnswers,
+			final Boolean withFeedbackQuestions) {
 		/* FIXME: not yet migrated - move to service layer */
 		throw new UnsupportedOperationException();
-//		ImportExportSession importExportSession = new ImportExportSession();
-//		Session session = getDatabaseDao().getSessionFromKeyword(sessionkey);
+//		final ImportExportSession importExportSession = new ImportExportSession();
+//		final Session session = getDatabaseDao().getSessionFromKeyword(sessionkey);
 //		importExportSession.setSessionFromSessionObject(session);
-//		List<Content> questionList = getDatabaseDao().getAllSkillQuestions(session);
-//		for (Content question : questionList) {
-//			List<de.thm.arsnova.entities.transport.Answer> answerList = new ArrayList<>();
+//		final List<Content> questionList = getDatabaseDao().getAllSkillQuestions(session);
+//		for (final Content question : questionList) {
+//			final List<de.thm.arsnova.entities.transport.Answer> answerList = new ArrayList<>();
 //			if (withAnswers) {
-//				for (Answer a : this.getDatabaseDao().getAllAnswers(question)) {
-//					de.thm.arsnova.entities.transport.Answer transportAnswer = new de.thm.arsnova.entities.transport.Answer(a);
+//				for (final Answer a : this.getDatabaseDao().getAllAnswers(question)) {
+//					final de.thm.arsnova.entities.transport.Answer transportAnswer = new de.thm.arsnova.entities.transport.Answer(a);
 //					answerList.add(transportAnswer);
 //				}
 //				// getAllAnswers does not grep for whole answer object so i need to add empty entries for abstentions
 //				int i = this.getDatabaseDao().getAbstentionAnswerCount(question.getId());
 //				for (int b = 0; b < i; b++) {
-//					de.thm.arsnova.entities.transport.Answer ans = new de.thm.arsnova.entities.transport.Answer();
+//					final de.thm.arsnova.entities.transport.Answer ans = new de.thm.arsnova.entities.transport.Answer();
 //					ans.setAnswerSubject("");
 //					ans.setAnswerImage("");
 //					ans.setAnswerText("");
@@ -401,8 +404,8 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 //			importExportSession.addQuestionWithAnswers(question, answerList);
 //		}
 //		if (withFeedbackQuestions) {
-//			List<de.thm.arsnova.entities.transport.Comment> interposedQuestionList = new ArrayList<>();
-//			for (Comment i : getDatabaseDao().getInterposedQuestions(session, 0, 0)) {
+//			final List<de.thm.arsnova.entities.transport.Comment> interposedQuestionList = new ArrayList<>();
+//			for (final Comment i : getDatabaseDao().getInterposedQuestions(session, 0, 0)) {
 //				de.thm.arsnova.entities.transport.Comment transportInterposedQuestion = new de.thm.arsnova.entities.transport.Comment(i);
 //				interposedQuestionList.add(transportInterposedQuestion);
 //			}
@@ -415,7 +418,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 //		return importExportSession;
 	}
 
-	private SessionInfo calculateSessionInfo(ImportExportSession importExportSession, Session session) {
+	private SessionInfo calculateSessionInfo(final ImportExportSession importExportSession, final Session session) {
 		int unreadComments = 0;
 		int numUnanswered = 0;
 		int numAnswers = 0;
@@ -445,12 +448,12 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	}
 
 	@Override
-	public List<Session> getSessionsForUsername(String username, final int start, final int limit) {
+	public List<Session> getSessionsForUsername(final String username, final int start, final int limit) {
 		final int qSkip = start > 0 ? start : -1;
 		final int qLimit = limit > 0 ? limit : -1;
 
 		/* TODO: Only load IDs and check against cache for data. */
-		List<Session> sessions = db.queryView(
+		return db.queryView(
 				createQuery("partial_by_sessiontype_creator_name")
 						.skip(qSkip)
 						.limit(qLimit)
@@ -458,8 +461,6 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 						.endKey(ComplexKey.of(null, username, ComplexKey.emptyObject()))
 						.includeDocs(true),
 				Session.class);
-
-		return sessions;
 	}
 
 	@Override
@@ -504,7 +505,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	}
 
 	private List<SessionInfo> getInfosForSessions(final List<Session> sessions) {
-		List<String> sessionIds = sessions.stream().map(Session::getId).collect(Collectors.toList());
+		final List<String> sessionIds = sessions.stream().map(Session::getId).collect(Collectors.toList());
 		final ViewQuery questionCountView = createQuery("by_sessionid").designDocId("_design/Content")
 				.group(true).keys(sessionIds);
 		final ViewQuery answerCountView = createQuery("by_sessionid").designDocId("_design/Answer")
@@ -520,91 +521,94 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	private List<SessionInfo> getInfosForVisitedSessions(final List<Session> sessions, final User user) {
 		final ViewQuery answeredQuestionsView = createQuery("by_user_sessionid").designDocId("_design/Answer")
 				.keys(sessions.stream().map(session -> ComplexKey.of(user.getUsername(), session.getId())).collect(Collectors.toList()));
-		final ViewQuery questionIdsView = createQuery("by_sessionid").designDocId("_design/Content")
+		final ViewQuery contentIdsView = createQuery("by_sessionid").designDocId("_design/Content")
 				.keys(sessions.stream().map(Session::getId).collect(Collectors.toList()));
 
-		return getVisitedSessionInfoData(sessions, answeredQuestionsView, questionIdsView);
+		return getVisitedSessionInfoData(sessions, answeredQuestionsView, contentIdsView);
 	}
 
-	private List<SessionInfo> getVisitedSessionInfoData(List<Session> sessions,
-														ViewQuery answeredQuestionsView, ViewQuery questionIdsView) {
+	private List<SessionInfo> getVisitedSessionInfoData(
+			final List<Session> sessions,
+			final ViewQuery answeredQuestionsView,
+			final ViewQuery contentIdsView) {
 		final Map<String, Set<String>> answeredQuestionsMap = new HashMap<>();
-		final Map<String, Set<String>> questionIdMap = new HashMap<>();
+		final Map<String, Set<String>> contentIdMap = new HashMap<>();
 
 		// Maps a session ID to a set of question IDs of answered questions of that session
 		for (final ViewResult.Row row : db.queryView(answeredQuestionsView).getRows()) {
 			final String sessionId = row.getKey();
-			final String questionId = row.getValue();
-			Set<String> questionIdsInSession = answeredQuestionsMap.get(sessionId);
-			if (questionIdsInSession == null) {
-				questionIdsInSession = new HashSet<>();
+			final String contentId = row.getValue();
+			Set<String> contentIdsInSession = answeredQuestionsMap.get(sessionId);
+			if (contentIdsInSession == null) {
+				contentIdsInSession = new HashSet<>();
 			}
-			questionIdsInSession.add(questionId);
-			answeredQuestionsMap.put(sessionId, questionIdsInSession);
+			contentIdsInSession.add(contentId);
+			answeredQuestionsMap.put(sessionId, contentIdsInSession);
 		}
 
 		// Maps a session ID to a set of question IDs of that session
-		for (final ViewResult.Row row : db.queryView(questionIdsView).getRows()) {
+		for (final ViewResult.Row row : db.queryView(contentIdsView).getRows()) {
 			final String sessionId = row.getKey();
-			final String questionId = row.getId();
-			Set<String> questionIdsInSession = questionIdMap.get(sessionId);
-			if (questionIdsInSession == null) {
-				questionIdsInSession = new HashSet<>();
+			final String contentId = row.getId();
+			Set<String> contentIdsInSession = contentIdMap.get(sessionId);
+			if (contentIdsInSession == null) {
+				contentIdsInSession = new HashSet<>();
 			}
-			questionIdsInSession.add(questionId);
-			questionIdMap.put(sessionId, questionIdsInSession);
+			contentIdsInSession.add(contentId);
+			contentIdMap.put(sessionId, contentIdsInSession);
 		}
 
 		// For each session, count the question IDs that are not yet answered
-		Map<String, Integer> unansweredQuestionsCountMap = new HashMap<>();
+		final Map<String, Integer> unansweredQuestionsCountMap = new HashMap<>();
 		for (final Session s : sessions) {
-			if (!questionIdMap.containsKey(s.getId())) {
+			if (!contentIdMap.containsKey(s.getId())) {
 				continue;
 			}
 			// Note: create a copy of the first set so that we don't modify the contents in the original set
-			Set<String> questionIdsInSession = new HashSet<>(questionIdMap.get(s.getId()));
-			Set<String> answeredQuestionIdsInSession = answeredQuestionsMap.get(s.getId());
-			if (answeredQuestionIdsInSession == null) {
-				answeredQuestionIdsInSession = new HashSet<>();
+			final Set<String> contentIdsInSession = new HashSet<>(contentIdMap.get(s.getId()));
+			Set<String> answeredContentIdsInSession = answeredQuestionsMap.get(s.getId());
+			if (answeredContentIdsInSession == null) {
+				answeredContentIdsInSession = new HashSet<>();
 			}
-			questionIdsInSession.removeAll(answeredQuestionIdsInSession);
-			unansweredQuestionsCountMap.put(s.getId(), questionIdsInSession.size());
+			contentIdsInSession.removeAll(answeredContentIdsInSession);
+			unansweredQuestionsCountMap.put(s.getId(), contentIdsInSession.size());
 		}
 
-		List<SessionInfo> sessionInfos = new ArrayList<>();
-		for (Session session : sessions) {
+		final List<SessionInfo> sessionInfos = new ArrayList<>();
+		for (final Session session : sessions) {
 			int numUnanswered = 0;
 
 			if (unansweredQuestionsCountMap.containsKey(session.getId())) {
 				numUnanswered = unansweredQuestionsCountMap.get(session.getId());
 			}
-			SessionInfo info = new SessionInfo(session);
+			final SessionInfo info = new SessionInfo(session);
 			info.setNumUnanswered(numUnanswered);
 			sessionInfos.add(info);
 		}
 		return sessionInfos;
 	}
 
-	private List<SessionInfo> getSessionInfoData(final List<Session> sessions,
-												 final ViewQuery questionCountView,
-												 final ViewQuery answerCountView,
-												 final ViewQuery commentCountView,
-												 final ViewQuery unreadCommentCountView) {
-		Map<String, Integer> questionCountMap = db.queryView(questionCountView).getRows()
+	private List<SessionInfo> getSessionInfoData(
+			final List<Session> sessions,
+			final ViewQuery questionCountView,
+			final ViewQuery answerCountView,
+			final ViewQuery commentCountView,
+			final ViewQuery unreadCommentCountView) {
+		final Map<String, Integer> questionCountMap = db.queryView(questionCountView).getRows()
 				.stream().map(row -> new AbstractMap.SimpleImmutableEntry<>(row.getKey(), row.getValueAsInt()))
 				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-		Map<String, Integer> answerCountMap = db.queryView(answerCountView).getRows()
+		final Map<String, Integer> answerCountMap = db.queryView(answerCountView).getRows()
 				.stream().map(row -> new AbstractMap.SimpleImmutableEntry<>(row.getKey(), row.getValueAsInt()))
 				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-		Map<String, Integer> commentCountMap = db.queryView(commentCountView).getRows()
+		final Map<String, Integer> commentCountMap = db.queryView(commentCountView).getRows()
 				.stream().map(row -> new AbstractMap.SimpleImmutableEntry<>(row.getKey(), row.getValueAsInt()))
 				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-		Map<String, Integer> unreadCommentCountMap = db.queryView(unreadCommentCountView).getRows()
+		final Map<String, Integer> unreadCommentCountMap = db.queryView(unreadCommentCountView).getRows()
 				.stream().map(row -> new AbstractMap.SimpleImmutableEntry<>(row.getKey(), row.getValueAsInt()))
 				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
 
-		List<SessionInfo> sessionInfos = new ArrayList<>();
-		for (Session session : sessions) {
+		final List<SessionInfo> sessionInfos = new ArrayList<>();
+		for (final Session session : sessions) {
 			int numQuestions = 0;
 			int numAnswers = 0;
 			int numComments = 0;
@@ -622,7 +626,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 				numUnreadComments = unreadCommentCountMap.get(session.getId());
 			}
 
-			SessionInfo info = new SessionInfo(session);
+			final SessionInfo info = new SessionInfo(session);
 			info.setNumQuestions(numQuestions);
 			info.setNumAnswers(numAnswers);
 			info.setNumInterposed(numComments);
@@ -636,7 +640,7 @@ public class CouchDbSessionRepository extends CouchDbRepositorySupport<Session>
 	public LoggedIn registerAsOnlineUser(final User user, final Session session) {
 		LoggedIn loggedIn = new LoggedIn();
 		try {
-			List<LoggedIn> loggedInList = db.queryView(createQuery("all").designDocId("_design/LoggedIn").key(user.getUsername()), LoggedIn.class);
+			final List<LoggedIn> loggedInList = db.queryView(createQuery("all").designDocId("_design/LoggedIn").key(user.getUsername()), LoggedIn.class);
 
 			if (!loggedInList.isEmpty()) {
 				loggedIn = loggedInList.get(0);
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionStatisticsRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionStatisticsRepository.java
index f98ea9e1a..8796f056e 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionStatisticsRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionStatisticsRepository.java
@@ -11,7 +11,7 @@ import org.ektorp.support.CouchDbRepositorySupport;
 import org.springframework.cache.annotation.Cacheable;
 
 public class CouchDbSessionStatisticsRepository extends CouchDbRepositorySupport implements SessionStatisticsRepository {
-	public CouchDbSessionStatisticsRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbSessionStatisticsRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(Object.class, db, "learning_progress", createIfNotExists);
 	}
 
@@ -33,21 +33,21 @@ public class CouchDbSessionStatisticsRepository extends CouchDbRepositorySupport
 
 		// collect mapping (questionId -> max value)
 		for (ViewResult.Row row : maximumValueResult) {
-			final String questionId = row.getKeyAsNode().get(1).asText();
+			final String contentId = row.getKeyAsNode().get(1).asText();
 			final JsonNode value = row.getValueAsNode();
 			final int questionScore = value.get("value").asInt();
 			final String questionVariant = value.get("questionVariant").asText();
 			final int piRound = value.get("piRound").asInt();
-			courseScore.addQuestion(questionId, questionVariant, piRound, questionScore);
+			courseScore.addQuestion(contentId, questionVariant, piRound, questionScore);
 		}
 		// collect mapping (questionId -> (user -> value))
 		for (ViewResult.Row row : answerSumResult) {
 			final String username = row.getKeyAsNode().get(1).asText();
 			final JsonNode value = row.getValueAsNode();
-			final String questionId = value.get("questionId").asText();
+			final String contentId = value.get("questionId").asText();
 			final int userscore = value.get("score").asInt();
 			final int piRound = value.get("piRound").asInt();
-			courseScore.addAnswer(questionId, piRound, username, userscore);
+			courseScore.addAnswer(contentId, piRound, username, userscore);
 		}
 		return courseScore;
 	}
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbStatisticsRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbStatisticsRepository.java
index 19c6838a2..f3b27feff 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbStatisticsRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbStatisticsRepository.java
@@ -16,7 +16,7 @@ import java.util.Set;
 public class CouchDbStatisticsRepository extends CouchDbRepositorySupport implements StatisticsRepository {
 	private static final Logger logger = LoggerFactory.getLogger(CouchDbStatisticsRepository.class);
 
-	public CouchDbStatisticsRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbStatisticsRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(Object.class, db, "statistics", createIfNotExists);
 	}
 
@@ -30,7 +30,7 @@ public class CouchDbStatisticsRepository extends CouchDbRepositorySupport implem
 			final ViewResult studentUserResult = db.queryView(createQuery("active_student_users").group(true));
 
 			if (!statsResult.isEmpty()) {
-				for (ViewResult.Row row: statsResult.getRows()) {
+				for (final ViewResult.Row row: statsResult.getRows()) {
 					final int value = row.getValueAsInt();
 					switch (row.getKey()) {
 						case "openSessions":
@@ -65,14 +65,14 @@ public class CouchDbStatisticsRepository extends CouchDbRepositorySupport implem
 				}
 			}
 			if (!creatorResult.isEmpty()) {
-				Set<String> creators = new HashSet<>();
+				final Set<String> creators = new HashSet<>();
 				for (ViewResult.Row row: statsResult.getRows()) {
 					creators.add(row.getKey());
 				}
 				stats.setCreators(creators.size());
 			}
 			if (!studentUserResult.isEmpty()) {
-				Set<String> students = new HashSet<>();
+				final Set<String> students = new HashSet<>();
 				for (ViewResult.Row row: statsResult.getRows()) {
 					students.add(row.getKey());
 				}
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbUserRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbUserRepository.java
index 5c88ab22a..6aec2b929 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbUserRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbUserRepository.java
@@ -37,7 +37,7 @@ public class CouchDbUserRepository extends CouchDbRepositorySupport<DbUser> impl
 
 	private static final Logger logger = LoggerFactory.getLogger(CouchDbUserRepository.class);
 
-	public CouchDbUserRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbUserRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(DbUser.class, db, createIfNotExists);
 	}
 
@@ -47,7 +47,7 @@ public class CouchDbUserRepository extends CouchDbRepositorySupport<DbUser> impl
 
 	@Override
 	public DbUser createOrUpdateUser(final DbUser user) {
-		String id = user.getId();
+		final String id = user.getId();
 
 		if (null != id) {
 			db.update(user);
@@ -59,8 +59,8 @@ public class CouchDbUserRepository extends CouchDbRepositorySupport<DbUser> impl
 	}
 
 	@Override
-	public DbUser findUserByUsername(String username) {
-		List<DbUser> users = queryView("by_username", username);
+	public DbUser findUserByUsername(final String username) {
+		final List<DbUser> users = queryView("by_username", username);
 
 		return !users.isEmpty() ? users.get(0) : null;
 	}
@@ -77,22 +77,22 @@ public class CouchDbUserRepository extends CouchDbRepositorySupport<DbUser> impl
 	}
 
 	@Override
-	public int deleteInactiveUsers(long lastActivityBefore) {
-		ViewQuery q = createQuery("by_creation_for_inactive").endKey(lastActivityBefore);
-		List<ViewResult.Row> rows = db.queryView(q).getRows();
+	public int deleteInactiveUsers(final long lastActivityBefore) {
+		final ViewQuery q = createQuery("by_creation_for_inactive").endKey(lastActivityBefore);
+		final List<ViewResult.Row> rows = db.queryView(q).getRows();
 
 		int count = 0;
 		final List<List<ViewResult.Row>> partitions = Lists.partition(rows, BULK_PARTITION_SIZE);
-		for (List<ViewResult.Row> partition: partitions) {
+		for (final List<ViewResult.Row> partition: partitions) {
 			final List<BulkDeleteDocument> newDocs = new ArrayList<>();
-			for (ViewResult.Row oldDoc : partition) {
+			for (final ViewResult.Row oldDoc : partition) {
 				final BulkDeleteDocument newDoc = new BulkDeleteDocument(oldDoc.getId(), oldDoc.getValue());
 				newDocs.add(newDoc);
 				logger.debug("Marked user document {} for deletion.", oldDoc.getId());
 			}
 
 			if (newDocs.size() > 0) {
-				List<DocumentOperationResult> results = db.executeBulk(newDocs);
+				final List<DocumentOperationResult> results = db.executeBulk(newDocs);
 				if (!results.isEmpty()) {
 					/* TODO: This condition should be improved so that it checks the operation results. */
 					count += newDocs.size();
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbVisitedSessionRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbVisitedSessionRepository.java
index 03b284087..a9bacfe27 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbVisitedSessionRepository.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbVisitedSessionRepository.java
@@ -25,18 +25,18 @@ public class CouchDbVisitedSessionRepository extends CouchDbRepositorySupport<Vi
 	@Autowired
 	private LogEntryRepository dbLogger;
 
-	public CouchDbVisitedSessionRepository(CouchDbConnector db, boolean createIfNotExists) {
+	public CouchDbVisitedSessionRepository(final CouchDbConnector db, final boolean createIfNotExists) {
 		super(VisitedSession.class, db, createIfNotExists);
 	}
 
 	@Override
-	public int deleteInactiveGuestVisitedSessionLists(long lastActivityBefore) {
+	public int deleteInactiveGuestVisitedSessionLists(final long lastActivityBefore) {
 		try {
-			ViewResult result = db.queryView(createQuery("by_last_activity_for_guests").endKey(lastActivityBefore));
+			final ViewResult result = db.queryView(createQuery("by_last_activity_for_guests").endKey(lastActivityBefore));
 
 			int count = 0;
-			List<List<ViewResult.Row>> partitions = Lists.partition(result.getRows(), BULK_PARTITION_SIZE);
-			for (List<ViewResult.Row> partition: partitions) {
+			final List<List<ViewResult.Row>> partitions = Lists.partition(result.getRows(), BULK_PARTITION_SIZE);
+			for (final List<ViewResult.Row> partition: partitions) {
 				final List<BulkDeleteDocument> newDocs = new ArrayList<>();
 				for (final ViewResult.Row oldDoc : partition) {
 					final BulkDeleteDocument newDoc = new BulkDeleteDocument(oldDoc.getId(), oldDoc.getValueAsNode().get("_rev").asText());
@@ -47,7 +47,7 @@ public class CouchDbVisitedSessionRepository extends CouchDbRepositorySupport<Vi
 				}
 
 				if (!newDocs.isEmpty()) {
-					List<DocumentOperationResult> results = db.executeBulk(newDocs);
+					final List<DocumentOperationResult> results = db.executeBulk(newDocs);
 					count += newDocs.size() - results.size();
 					if (!results.isEmpty()) {
 						logger.error("Could not bulk delete some visited session lists.");
@@ -61,7 +61,7 @@ public class CouchDbVisitedSessionRepository extends CouchDbRepositorySupport<Vi
 			}
 
 			return count;
-		} catch (DbAccessException e) {
+		} catch (final DbAccessException e) {
 			logger.error("Could not delete visited session lists of inactive users.", e);
 		}
 
diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/InitializingCouchDbConnector.java b/src/main/java/de/thm/arsnova/persistance/couchdb/InitializingCouchDbConnector.java
index d968a7ae0..126504089 100644
--- a/src/main/java/de/thm/arsnova/persistance/couchdb/InitializingCouchDbConnector.java
+++ b/src/main/java/de/thm/arsnova/persistance/couchdb/InitializingCouchDbConnector.java
@@ -30,11 +30,11 @@ public class InitializingCouchDbConnector extends StdCouchDbConnector implements
 
 	private ResourceLoader resourceLoader;
 
-	public InitializingCouchDbConnector(String databaseName, CouchDbInstance dbInstance) {
+	public InitializingCouchDbConnector(final String databaseName, final CouchDbInstance dbInstance) {
 		super(databaseName, dbInstance);
 	}
 
-	public InitializingCouchDbConnector(String databaseName, CouchDbInstance dbi, ObjectMapperFactory om) {
+	public InitializingCouchDbConnector(final String databaseName, final CouchDbInstance dbi, final ObjectMapperFactory om) {
 		super(databaseName, dbi, om);
 	}
 
@@ -42,14 +42,14 @@ public class InitializingCouchDbConnector extends StdCouchDbConnector implements
 		final ScriptEngine engine = new ScriptEngineManager().getEngineByMimeType("application/javascript");
 		engine.eval(new InputStreamReader(new ClassPathResource("couchdb/jsToJson.js").getInputStream()));
 
-		PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
-		Resource[] resources = resolver.getResources("classpath:couchdb/*.design.js");
+		final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+		final Resource[] resources = resolver.getResources("classpath:couchdb/*.design.js");
 		for (Resource resource : resources) {
 			logger.debug("Loading CouchDB design doc: {}", resource.getFilename());
-			String js = FileCopyUtils.copyToString(new InputStreamReader(resource.getInputStream()));
+			final String js = FileCopyUtils.copyToString(new InputStreamReader(resource.getInputStream()));
 			/* Reset designDoc before parsing a new one. */
 			engine.eval("var designDoc = null;" + js);
-			Bindings jsonObject = (Bindings) engine.eval("jsToJson(designDoc)");
+			final Bindings jsonObject = (Bindings) engine.eval("jsToJson(designDoc)");
 			docs.add(jsonObject);
 		}
 	}
@@ -64,10 +64,10 @@ public class InitializingCouchDbConnector extends StdCouchDbConnector implements
 				}
 			}
 			try {
-				String rev = getCurrentRevision((String) doc.get("_id"));
+				final String rev = getCurrentRevision((String) doc.get("_id"));
 				doc.put("_rev", rev);
 				update(doc);
-			} catch (DocumentNotFoundException e) {
+			} catch (final DocumentNotFoundException e) {
 				create(doc);
 			}
 		});
@@ -80,7 +80,7 @@ public class InitializingCouchDbConnector extends StdCouchDbConnector implements
 	}
 
 	@Override
-	public void setResourceLoader(ResourceLoader resourceLoader) {
+	public void setResourceLoader(final ResourceLoader resourceLoader) {
 		this.resourceLoader = resourceLoader;
 	}
 }
diff --git a/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java b/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java
index 9a15135d3..46a50ddc2 100644
--- a/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java
+++ b/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java
@@ -38,7 +38,7 @@ public class CommentServiceImpl implements CommentService {
 	@PreAuthorize("isAuthenticated()")
 	public boolean saveQuestion(final Comment comment) {
 		final Session session = sessionRepository.getSessionFromKeyword(comment.getSessionId());
-		final Comment result = commentRepository.saveQuestion(session, comment, userService.getCurrentUser());
+		final Comment result = commentRepository.saveQuestion(session.getId(), comment, userService.getCurrentUser());
 
 		if (null != result) {
 			final NewCommentEvent event = new NewCommentEvent(this, session, result);
@@ -71,9 +71,9 @@ public class CommentServiceImpl implements CommentService {
 		}
 		final User user = getCurrentUser();
 		if (session.isCreator(user)) {
-			commentRepository.deleteAllInterposedQuestions(session);
+			commentRepository.deleteAllInterposedQuestions(session.getId());
 		} else {
-			commentRepository.deleteAllInterposedQuestions(session, user);
+			commentRepository.deleteAllInterposedQuestions(session.getId(), user);
 		}
 	}
 
@@ -91,14 +91,14 @@ public class CommentServiceImpl implements CommentService {
 			throw new NotFoundException();
 		}
 		if (username == null) {
-			return commentRepository.getInterposedReadingCount(session);
+			return commentRepository.getInterposedReadingCount(session.getId());
 		} else {
 			User currentUser = userService.getCurrentUser();
 			if (!currentUser.getUsername().equals(username)) {
 				throw new ForbiddenException();
 			}
 
-			return commentRepository.getInterposedReadingCount(session, currentUser);
+			return commentRepository.getInterposedReadingCount(session.getId(), currentUser);
 		}
 	}
 
@@ -108,9 +108,9 @@ public class CommentServiceImpl implements CommentService {
 		final Session session = this.getSession(sessionKey);
 		final User user = getCurrentUser();
 		if (session.isCreator(user)) {
-			return commentRepository.getInterposedQuestions(session, offset, limit);
+			return commentRepository.getInterposedQuestions(session.getId(), offset, limit);
 		} else {
-			return commentRepository.getInterposedQuestions(session, user, offset, limit);
+			return commentRepository.getInterposedQuestions(session.getId(), user, offset, limit);
 		}
 	}
 
diff --git a/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java b/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java
index aa03b62e6..f4e5bc665 100644
--- a/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java
+++ b/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java
@@ -81,9 +81,9 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		final Session session = getSession(sessionkey);
 		final User user = userService.getCurrentUser();
 		if (session.isCreator(user)) {
-			return contentRepository.getSkillQuestionsForTeachers(session);
+			return contentRepository.getSkillQuestionsForTeachers(session.getId());
 		} else {
-			return contentRepository.getSkillQuestionsForUsers(session);
+			return contentRepository.getSkillQuestionsForUsers(session.getId());
 		}
 	}
 
@@ -91,7 +91,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	@PreAuthorize("isAuthenticated()")
 	public int getSkillQuestionCount(final String sessionkey) {
 		final Session session = sessionRepository.getSessionFromKeyword(sessionkey);
-		return contentRepository.getSkillQuestionCount(session);
+		return contentRepository.getSkillQuestionCount(session.getId());
 	}
 
 	/* FIXME: #content.getSessionKeyword() cannot be checked since keyword is no longer set for content. */
@@ -118,7 +118,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 			}
 		}
 
-		final Content result = contentRepository.saveQuestion(session, content);
+		final Content result = contentRepository.saveQuestion(session.getId(), content);
 
 		final NewQuestionEvent event = new NewQuestionEvent(this, session, result);
 		this.publisher.publishEvent(event);
@@ -153,7 +153,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if (session == null) {
 			throw new UnauthorizedException();
 		}
-		contentRepository.deleteQuestionWithAnswers(content);
+		contentRepository.deleteQuestionWithAnswers(content.getId());
 
 		final DeleteQuestionEvent event = new DeleteQuestionEvent(this, session, content);
 		this.publisher.publishEvent(event);
@@ -163,7 +163,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	@PreAuthorize("isAuthenticated() and hasPermission(#sessionKeyword, 'session', 'owner')")
 	public void deleteAllQuestions(final String sessionKeyword) {
 		final Session session = getSessionWithAuthCheck(sessionKeyword);
-		contentRepository.deleteAllQuestionsWithAnswers(session);
+		contentRepository.deleteAllQuestionsWithAnswers(session.getId());
 
 		final DeleteAllQuestionsEvent event = new DeleteAllQuestionsEvent(this, session);
 		this.publisher.publishEvent(event);
@@ -259,7 +259,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		}
 
 		content.resetRoundManagementState();
-		answerRepository.deleteAnswers(content);
+		answerRepository.deleteAnswers(content.getId());
 		update(content);
 		this.publisher.publishEvent(new PiRoundResetEvent(this, session, content));
 	}
@@ -294,7 +294,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if (!session.isCreator(user)) {
 			throw new UnauthorizedException();
 		}
-		contentRepository.setVotingAdmissions(session, disableVoting, contents);
+		contentRepository.setVotingAdmissions(session.getId(), disableVoting, contents);
 		ArsnovaEvent event;
 		if (disableVoting) {
 			event = new LockVotesEvent(this, session, contents);
@@ -312,7 +312,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if (!session.isCreator(user)) {
 			throw new UnauthorizedException();
 		}
-		final List<Content> contents = contentRepository.setVotingAdmissionForAllQuestions(session, disableVoting);
+		final List<Content> contents = contentRepository.setVotingAdmissionForAllQuestions(session.getId(), disableVoting);
 		ArsnovaEvent event;
 		if (disableVoting) {
 			event = new LockVotesEvent(this, session, contents);
@@ -337,7 +337,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		final Content content = contentRepository.getQuestion(questionId);
 		content.resetQuestionState();
 		contentRepository.updateQuestion(content);
-		answerRepository.deleteAnswers(content);
+		answerRepository.deleteAnswers(content.getId());
 	}
 
 	@Override
@@ -345,7 +345,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	public List<String> getUnAnsweredQuestionIds(final String sessionKey) {
 		final User user = getCurrentUser();
 		final Session session = getSession(sessionKey);
-		return contentRepository.getUnAnsweredQuestionIds(session, user);
+		return contentRepository.getUnAnsweredQuestionIds(session.getId(), user);
 	}
 
 	private User getCurrentUser() {
@@ -391,7 +391,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		}
 		return "freetext".equals(content.getQuestionType())
 				? getFreetextAnswers(questionId, offset, limit)
-						: answerRepository.getAnswers(content, piRound);
+						: answerRepository.getAnswers(content.getId(), piRound);
 	}
 
 	@Override
@@ -404,7 +404,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if ("freetext".equals(content.getQuestionType())) {
 			return getFreetextAnswers(questionId, offset, limit);
 		} else {
-			return answerRepository.getAnswers(content);
+			return answerRepository.getAnswers(content.getId(), content.getPiRound());
 		}
 	}
 
@@ -418,7 +418,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if ("freetext".equals(content.getQuestionType())) {
 			return getFreetextAnswers(questionId, offset, limit);
 		} else {
-			return answerRepository.getAllAnswers(content);
+			return answerRepository.getAllAnswers(content.getId());
 		}
 	}
 
@@ -431,9 +431,9 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		}
 
 		if ("freetext".equals(content.getQuestionType())) {
-			return answerRepository.getTotalAnswerCountByQuestion(content);
+			return answerRepository.getTotalAnswerCountByQuestion(content.getId());
 		} else {
-			return answerRepository.getAnswerCount(content, content.getPiRound());
+			return answerRepository.getAnswerCount(content.getId(), content.getPiRound());
 		}
 	}
 
@@ -445,7 +445,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 			return 0;
 		}
 
-		return answerRepository.getAnswerCount(content, piRound);
+		return answerRepository.getAnswerCount(content.getId(), piRound);
 	}
 
 	@Override
@@ -467,7 +467,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 			return 0;
 		}
 
-		return answerRepository.getTotalAnswerCountByQuestion(content);
+		return answerRepository.getTotalAnswerCountByQuestion(content.getId());
 	}
 
 	@Override
@@ -490,14 +490,14 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	public List<Answer> getMyAnswers(final String sessionKey) {
 		final Session session = getSession(sessionKey);
 		// Load contents first because we are only interested in answers of the latest piRound.
-		final List<Content> contents = contentRepository.getSkillQuestionsForUsers(session);
+		final List<Content> contents = contentRepository.getSkillQuestionsForUsers(session.getId());
 		final Map<String, Content> questionIdToQuestion = new HashMap<>();
 		for (final Content content : contents) {
 			questionIdToQuestion.put(content.getId(), content);
 		}
 
 		/* filter answers by active piRound per question */
-		final List<Answer> answers = answerRepository.getMyAnswers(userService.getCurrentUser(), session);
+		final List<Answer> answers = answerRepository.getMyAnswers(userService.getCurrentUser(), session.getId());
 		final List<Answer> filteredAnswers = new ArrayList<>();
 		for (final Answer answer : answers) {
 			final Content content = questionIdToQuestion.get(answer.getQuestionId());
@@ -640,9 +640,9 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		final Session session = getSession(sessionkey);
 		final User user = userService.getCurrentUser();
 		if (session.isCreator(user)) {
-			return contentRepository.getLectureQuestionsForTeachers(session);
+			return contentRepository.getLectureQuestionsForTeachers(session.getId());
 		} else {
-			return contentRepository.getLectureQuestionsForUsers(session);
+			return contentRepository.getLectureQuestionsForUsers(session.getId());
 		}
 	}
 
@@ -652,9 +652,9 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		final Session session = getSession(sessionkey);
 		final User user = userService.getCurrentUser();
 		if (session.isCreator(user)) {
-			return contentRepository.getFlashcardsForTeachers(session);
+			return contentRepository.getFlashcardsForTeachers(session.getId());
 		} else {
-			return contentRepository.getFlashcardsForUsers(session);
+			return contentRepository.getFlashcardsForUsers(session.getId());
 		}
 	}
 
@@ -664,9 +664,9 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		final Session session = getSession(sessionkey);
 		final User user = userService.getCurrentUser();
 		if (session.isCreator(user)) {
-			return contentRepository.getPreparationQuestionsForTeachers(session);
+			return contentRepository.getPreparationQuestionsForTeachers(session.getId());
 		} else {
-			return contentRepository.getPreparationQuestionsForUsers(session);
+			return contentRepository.getPreparationQuestionsForUsers(session.getId());
 		}
 	}
 
@@ -693,19 +693,19 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	@Override
 	@PreAuthorize("isAuthenticated()")
 	public int getLectureQuestionCount(final String sessionkey) {
-		return contentRepository.getLectureQuestionCount(getSession(sessionkey));
+		return contentRepository.getLectureQuestionCount(getSession(sessionkey).getId());
 	}
 
 	@Override
 	@PreAuthorize("isAuthenticated()")
 	public int getFlashcardCount(final String sessionkey) {
-		return contentRepository.getFlashcardCount(getSession(sessionkey));
+		return contentRepository.getFlashcardCount(getSession(sessionkey).getId());
 	}
 
 	@Override
 	@PreAuthorize("isAuthenticated()")
 	public int getPreparationQuestionCount(final String sessionkey) {
-		return contentRepository.getPreparationQuestionCount(getSession(sessionkey));
+		return contentRepository.getPreparationQuestionCount(getSession(sessionkey).getId());
 	}
 
 	@Override
@@ -720,7 +720,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	 */
 	@Override
 	public int countLectureQuestionAnswersInternal(final String sessionkey) {
-		return answerRepository.countLectureQuestionAnswers(getSession(sessionkey));
+		return answerRepository.countLectureQuestionAnswers(getSession(sessionkey).getId());
 	}
 
 	@Override
@@ -733,7 +733,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		}
 
 		map.put("_id", questionId);
-		map.put("answers", answerRepository.getAnswerCount(content, content.getPiRound()));
+		map.put("answers", answerRepository.getAnswerCount(content.getId(), content.getPiRound()));
 		map.put("abstentions", answerRepository.getAbstentionAnswerCount(questionId));
 
 		return map;
@@ -751,7 +751,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	 */
 	@Override
 	public int countPreparationQuestionAnswersInternal(final String sessionkey) {
-		return answerRepository.countPreparationQuestionAnswers(getSession(sessionkey));
+		return answerRepository.countPreparationQuestionAnswers(getSession(sessionkey).getId());
 	}
 
 	/*
@@ -760,28 +760,28 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	 */
 	@Override
 	public int countFlashcardsForUserInternal(final String sessionkey) {
-		return contentRepository.getFlashcardsForUsers(getSession(sessionkey)).size();
+		return contentRepository.getFlashcardsForUsers(getSession(sessionkey).getId()).size();
 	}
 
 	@Override
 	@PreAuthorize("isAuthenticated()")
 	public void deleteLectureQuestions(final String sessionkey) {
 		final Session session = getSessionWithAuthCheck(sessionkey);
-		contentRepository.deleteAllLectureQuestionsWithAnswers(session);
+		contentRepository.deleteAllLectureQuestionsWithAnswers(session.getId());
 	}
 
 	@Override
 	@PreAuthorize("isAuthenticated()")
 	public void deleteFlashcards(final String sessionkey) {
 		final Session session = getSessionWithAuthCheck(sessionkey);
-		contentRepository.deleteAllFlashcardsWithAnswers(session);
+		contentRepository.deleteAllFlashcardsWithAnswers(session.getId());
 	}
 
 	@Override
 	@PreAuthorize("isAuthenticated()")
 	public void deletePreparationQuestions(final String sessionkey) {
 		final Session session = getSessionWithAuthCheck(sessionkey);
-		contentRepository.deleteAllPreparationQuestionsWithAnswers(session);
+		contentRepository.deleteAllPreparationQuestionsWithAnswers(session.getId());
 	}
 
 	@Override
@@ -794,7 +794,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	@Override
 	public List<String> getUnAnsweredLectureQuestionIds(final String sessionkey, final User user) {
 		final Session session = getSession(sessionkey);
-		return contentRepository.getUnAnsweredLectureQuestionIds(session, user);
+		return contentRepository.getUnAnsweredLectureQuestionIds(session.getId(), user);
 	}
 
 	@Override
@@ -807,7 +807,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	@Override
 	public List<String> getUnAnsweredPreparationQuestionIds(final String sessionkey, final User user) {
 		final Session session = getSession(sessionkey);
-		return contentRepository.getUnAnsweredPreparationQuestionIds(session, user);
+		return contentRepository.getUnAnsweredPreparationQuestionIds(session.getId(), user);
 	}
 
 	@Override
@@ -818,7 +818,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if (!session.isCreator(user)) {
 			throw new UnauthorizedException();
 		}
-		final List<Content> contents = contentRepository.publishAllQuestions(session, publish);
+		final List<Content> contents = contentRepository.publishAllQuestions(session.getId(), publish);
 		ArsnovaEvent event;
 		if (publish) {
 			event = new UnlockQuestionsEvent(this, session, contents);
@@ -836,7 +836,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if (!session.isCreator(user)) {
 			throw new UnauthorizedException();
 		}
-		contentRepository.publishQuestions(session, publish, contents);
+		contentRepository.publishQuestions(session.getId(), publish, contents);
 		ArsnovaEvent event;
 		if (publish) {
 			event = new UnlockQuestionsEvent(this, session, contents);
@@ -854,7 +854,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 		if (!session.isCreator(user)) {
 			throw new UnauthorizedException();
 		}
-		answerRepository.deleteAllQuestionsAnswers(session);
+		answerRepository.deleteAllQuestionsAnswers(session.getId());
 
 		this.publisher.publishEvent(new DeleteAllQuestionsAnswersEvent(this, session));
 	}
@@ -863,7 +863,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	@PreAuthorize("isAuthenticated() and hasPermission(#sessionkey, 'session', 'owner')")
 	public void deleteAllPreparationAnswers(String sessionkey) {
 		final Session session = getSession(sessionkey);
-		answerRepository.deleteAllPreparationAnswers(session);
+		answerRepository.deleteAllPreparationAnswers(session.getId());
 
 		this.publisher.publishEvent(new DeleteAllPreparationAnswersEvent(this, session));
 	}
@@ -872,7 +872,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli
 	@PreAuthorize("isAuthenticated() and hasPermission(#sessionkey, 'session', 'owner')")
 	public void deleteAllLectureAnswers(String sessionkey) {
 		final Session session = getSession(sessionkey);
-		answerRepository.deleteAllLectureAnswers(session);
+		answerRepository.deleteAllLectureAnswers(session.getId());
 
 		this.publisher.publishEvent(new DeleteAllLectureAnswersEvent(this, session));
 	}
diff --git a/src/site/markdown/development/caching.md b/src/site/markdown/development/caching.md
index 01d4a81cc..108591d71 100644
--- a/src/site/markdown/development/caching.md
+++ b/src/site/markdown/development/caching.md
@@ -46,10 +46,10 @@ Here is a list of all caches, their keys, and a short description.
 
 Cache name | Key | Description
 -----------|-----|------------
-`skillquestions`| `Session` entity | Contains all questions for the specified session irrespective of their variant.
-`lecturequestions` | `Session` entity | Contains all "lecture" variant questions for the specified session.
-`preparationquestions` | `Session` entity | Contains all "preparation" variant questions for the specified session.
-`flashcardquestions` | `Session` entity | Contains all "flashcard" variant questions for the specified session.
+`skillquestions`| database id of session | Contains all questions for the specified session irrespective of their variant.
+`lecturequestions` | database id of session | Contains all "lecture" variant questions for the specified session.
+`preparationquestions` | database id of session | Contains all "preparation" variant questions for the specified session.
+`flashcardquestions` | database id of session | Contains all "flashcard" variant questions for the specified session.
 `questions` | `Question` entity | Contains single question objects.
 `questions` | database id of question | Although it shares the name of the previously mentioned cache, it is in essence a different cache because the keys are different. This means that the same `Question` object might be associated with two different keys.
 `answers`| `Question` entity | Contains single answer objects.
-- 
GitLab