diff --git a/apps/comments/composer/composer/autoload_classmap.php b/apps/comments/composer/composer/autoload_classmap.php
index c1cdce7d146a6a721e7b98fde0df89630e170c8c..d5d51c7a12c5a9776d72c78da21893a2aa0fa6a4 100644
--- a/apps/comments/composer/composer/autoload_classmap.php
+++ b/apps/comments/composer/composer/autoload_classmap.php
@@ -16,6 +16,7 @@ return array(
     'OCA\\Comments\\Controller\\Notifications' => $baseDir . '/../lib/Controller/Notifications.php',
     'OCA\\Comments\\EventHandler' => $baseDir . '/../lib/EventHandler.php',
     'OCA\\Comments\\JSSettingsHelper' => $baseDir . '/../lib/JSSettingsHelper.php',
+    'OCA\\Comments\\Listener\\CommentsEntityEventListener' => $baseDir . '/../lib/Listener/CommentsEntityEventListener.php',
     'OCA\\Comments\\Listener\\LoadAdditionalScripts' => $baseDir . '/../lib/Listener/LoadAdditionalScripts.php',
     'OCA\\Comments\\Listener\\LoadSidebarScripts' => $baseDir . '/../lib/Listener/LoadSidebarScripts.php',
     'OCA\\Comments\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
diff --git a/apps/comments/composer/composer/autoload_static.php b/apps/comments/composer/composer/autoload_static.php
index b38ae5841a018f87c885bc94dac2356144b650d5..1292415290ba84cc15fef8943f738783f1962441 100644
--- a/apps/comments/composer/composer/autoload_static.php
+++ b/apps/comments/composer/composer/autoload_static.php
@@ -31,6 +31,7 @@ class ComposerStaticInitComments
         'OCA\\Comments\\Controller\\Notifications' => __DIR__ . '/..' . '/../lib/Controller/Notifications.php',
         'OCA\\Comments\\EventHandler' => __DIR__ . '/..' . '/../lib/EventHandler.php',
         'OCA\\Comments\\JSSettingsHelper' => __DIR__ . '/..' . '/../lib/JSSettingsHelper.php',
+        'OCA\\Comments\\Listener\\CommentsEntityEventListener' => __DIR__ . '/..' . '/../lib/Listener/CommentsEntityEventListener.php',
         'OCA\\Comments\\Listener\\LoadAdditionalScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScripts.php',
         'OCA\\Comments\\Listener\\LoadSidebarScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarScripts.php',
         'OCA\\Comments\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php
index 7f3235eb62d6e2cb153c16539346eb10ea5b02c4..8bcf17b2afe433182a0813a28695127b5df973a6 100644
--- a/apps/comments/lib/AppInfo/Application.php
+++ b/apps/comments/lib/AppInfo/Application.php
@@ -31,6 +31,7 @@ use OCA\Comments\Capabilities;
 use OCA\Comments\Controller\Notifications;
 use OCA\Comments\EventHandler;
 use OCA\Comments\JSSettingsHelper;
+use OCA\Comments\Listener\CommentsEntityEventListener;
 use OCA\Comments\Listener\LoadAdditionalScripts;
 use OCA\Comments\Listener\LoadSidebarScripts;
 use OCA\Comments\Notification\Notifier;
@@ -38,60 +39,55 @@ use OCA\Comments\Search\Provider;
 use OCA\Files\Event\LoadAdditionalScriptsEvent;
 use OCA\Files\Event\LoadSidebar;
 use OCP\AppFramework\App;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
 use OCP\Comments\CommentsEntityEvent;
-use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IServerContainer;
 use OCP\Util;
 
-class Application extends App {
+class Application extends App implements IBootstrap {
 	public const APP_ID = 'comments';
 
 	public function __construct(array $urlParams = []) {
 		parent::__construct(self::APP_ID, $urlParams);
-		$container = $this->getContainer();
-
-		$container->registerAlias('NotificationsController', Notifications::class);
-
-		$jsSettingsHelper = new JSSettingsHelper($container->getServer());
-		Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
-
-		$this->register();
 	}
 
-	private function register() {
-		$server = $this->getContainer()->getServer();
-
-		/** @var IEventDispatcher $newDispatcher */
-		$dispatcher = $server->query(IEventDispatcher::class);
+	public function register(IRegistrationContext $context): void {
+		$context->registerCapability(Capabilities::class);
 
-		$this->registerEventsScripts($dispatcher);
-		$this->registerDavEntity($dispatcher);
-		$this->registerNotifier();
-		$this->registerCommentsEventHandler();
+		$context->registerServiceAlias('NotificationsController', Notifications::class);
 
-		$this->getContainer()->registerCapability(Capabilities::class);
-		$server->getSearch()->registerProvider(Provider::class, ['apps' => ['files']]);
+		$context->registerEventListener(
+			LoadAdditionalScriptsEvent::class,
+			LoadAdditionalScripts::class
+		);
+		$context->registerEventListener(
+			LoadSidebar::class,
+			LoadSidebarScripts::class
+		);
+		$context->registerEventListener(
+			CommentsEntityEvent::EVENT_ENTITY,
+			CommentsEntityEventListener::class
+		);
 	}
 
-	protected function registerEventsScripts(IEventDispatcher $dispatcher) {
-		$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
-		$dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarScripts::class);
-	}
+	public function boot(IBootContext $context): void {
+		$this->registerNotifier($context->getServerContainer());
+		$this->registerCommentsEventHandler($context->getServerContainer());
 
-	protected function registerDavEntity(IEventDispatcher $dispatcher) {
-		$dispatcher->addListener(CommentsEntityEvent::EVENT_ENTITY, function (CommentsEntityEvent $event) {
-			$event->addEntityCollection('files', function ($name) {
-				$nodes = \OC::$server->getUserFolder()->getById((int)$name);
-				return !empty($nodes);
-			});
-		});
+		$jsSettingsHelper = new JSSettingsHelper($context->getServerContainer());
+		Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
+
+		$context->getServerContainer()->getSearch()->registerProvider(Provider::class, ['apps' => ['files']]);
 	}
 
-	protected function registerNotifier() {
-		$this->getContainer()->getServer()->getNotificationManager()->registerNotifierService(Notifier::class);
+	protected function registerNotifier(IServerContainer $container) {
+		$container->getNotificationManager()->registerNotifierService(Notifier::class);
 	}
 
-	protected function registerCommentsEventHandler() {
-		$this->getContainer()->getServer()->getCommentsManager()->registerEventHandler(function () {
+	protected function registerCommentsEventHandler(IServerContainer $container) {
+		$container->getCommentsManager()->registerEventHandler(function () {
 			return $this->getContainer()->query(EventHandler::class);
 		});
 	}
diff --git a/apps/comments/lib/Listener/CommentsEntityEventListener.php b/apps/comments/lib/Listener/CommentsEntityEventListener.php
new file mode 100644
index 0000000000000000000000000000000000000000..c08d992405f380718a15b4e656165501b7b7bb0f
--- /dev/null
+++ b/apps/comments/lib/Listener/CommentsEntityEventListener.php
@@ -0,0 +1,44 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace OCA\Comments\Listener;
+
+use OCP\Comments\CommentsEntityEvent;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+
+class CommentsEntityEventListener implements IEventListener {
+	public function handle(Event $event): void {
+		if (!($event instanceof CommentsEntityEvent)) {
+			// Unrelated
+			return;
+		}
+
+		$event->addEntityCollection('files', function ($name) {
+			$nodes = \OC::$server->getUserFolder()->getById((int)$name);
+			return !empty($nodes);
+		});
+	}
+}