diff --git a/gajim/common/const.py b/gajim/common/const.py
index 94e453df33c33cdc45dae23e65de73f17852ccc7..2dd2573b43142fe87ade76b379c7f07875fd1217 100644
--- a/gajim/common/const.py
+++ b/gajim/common/const.py
@@ -200,6 +200,23 @@ class MUCUser(IntEnum):
     AFFILIATION_TEXT = 4
 
 
+EME_MESSAGES = {
+    'urn:xmpp:otr:0':
+        _('This message was encrypted with OTR '
+          'and could not be decrypted.'),
+    'jabber:x:encrypted':
+        _('This message was encrypted with Legacy '
+          'OpenPGP and could not be decrypted. You can install '
+          'the PGP plugin to handle those messages.'),
+    'urn:xmpp:openpgp:0':
+        _('This message was encrypted with '
+          'OpenPGP for XMPP and could not be decrypted.'),
+    'fallback':
+        _('This message was encrypted with %s '
+          'and could not be decrypted.')
+}
+
+
 ACTIVITIES = {
     'doing_chores': {
         'category': _('Doing Chores'),
diff --git a/gajim/common/modules/mam.py b/gajim/common/modules/mam.py
index 8f258b91a2a329971eaab648055d68437f1d1580..4466e25f3bf6e5c262747f3c9b3086ca870e1299 100644
--- a/gajim/common/modules/mam.py
+++ b/gajim/common/modules/mam.py
@@ -33,7 +33,7 @@ from gajim.common.helpers import AdditionalDataDict
 from gajim.common.modules.misc import parse_delay
 from gajim.common.modules.misc import parse_oob
 from gajim.common.modules.misc import parse_correction
-from gajim.common.modules.misc import parse_eme
+from gajim.common.modules.util import get_eme_message
 
 log = logging.getLogger('gajim.c.m.archiving')
 
@@ -170,11 +170,9 @@ class MAM:
         else:
             app.plugin_manager.extension_point(
                 'decrypt', self._con, event, self._decryption_finished)
-
             if not event.encrypted:
-                eme = parse_eme(event.message)
-                if eme is not None:
-                    event.msgtxt = eme
+                if properties.eme is not None:
+                    event.msgtxt = get_eme_message(properties.eme)
                 self._decryption_finished(event)
 
         raise nbxmpp.NodeProcessed
diff --git a/gajim/common/modules/message.py b/gajim/common/modules/message.py
index b5e9c8c6f3358203de28e0604540602a86ab88a4..f0a931ea5178d1d9838c3f17e0edea07d414e541 100644
--- a/gajim/common/modules/message.py
+++ b/gajim/common/modules/message.py
@@ -28,10 +28,10 @@ from gajim.common.nec import NetworkIncomingEvent
 from gajim.common.nec import NetworkEvent
 from gajim.common.helpers import AdditionalDataDict
 from gajim.common.const import KindConstant
+from gajim.common.modules.util import get_eme_message
 from gajim.common.modules.security_labels import parse_securitylabel
 from gajim.common.modules.user_nickname import parse_nickname
 from gajim.common.modules.misc import parse_delay
-from gajim.common.modules.misc import parse_eme
 from gajim.common.modules.misc import parse_correction
 from gajim.common.modules.misc import parse_attention
 from gajim.common.modules.misc import parse_form
@@ -187,9 +187,8 @@ class Message:
             app.plugin_manager.extension_point(
                 'decrypt', self._con, event, self._on_message_decrypted)
             if not event.encrypted:
-                eme = parse_eme(event.stanza)
-                if eme is not None:
-                    event.msgtxt = eme
+                if properties.eme is not None:
+                    event.msgtxt = get_eme_message(properties.eme)
                 self._on_message_decrypted(event)
 
     def _on_message_decrypted(self, event):
diff --git a/gajim/common/modules/misc.py b/gajim/common/modules/misc.py
index e0358adaa9c1fef6756177ef7cac25bb00842e3b..c70cf7ed78e7ac3f944e08d88bc9a7012abdd798 100644
--- a/gajim/common/modules/misc.py
+++ b/gajim/common/modules/misc.py
@@ -19,50 +19,11 @@ import logging
 import nbxmpp
 
 from gajim.common import app
-from gajim.common.i18n import _
 from gajim.common.modules.date_and_time import parse_datetime
 
 log = logging.getLogger('gajim.c.m.misc')
 
 
-# XEP-0380: Explicit Message Encryption
-
-_eme_namespaces = {
-    'urn:xmpp:otr:0':
-        _('This message was encrypted with OTR '
-          'and could not be decrypted.'),
-    'jabber:x:encrypted':
-        _('This message was encrypted with Legacy '
-          'OpenPGP and could not be decrypted. You can install '
-          'the PGP plugin to handle those messages.'),
-    'urn:xmpp:openpgp:0':
-        _('This message was encrypted with '
-          'OpenPGP for XMPP and could not be decrypted.'),
-    'fallback':
-        _('This message was encrypted with %s '
-          'and could not be decrypted.')
-}
-
-
-def parse_eme(stanza):
-    enc_tag = stanza.getTag('encryption', namespace=nbxmpp.NS_EME)
-    if enc_tag is None:
-        return
-
-    ns = enc_tag.getAttr('namespace')
-    if ns is None:
-        log.warning('No namespace on EME message')
-        return
-
-    if ns in _eme_namespaces:
-        log.info('Found not decrypted message: %s', ns)
-        return _eme_namespaces.get(ns)
-
-    enc_name = enc_tag.getAttr('name')
-    log.info('Found not decrypted message: %s', enc_name or ns)
-    return _eme_namespaces.get('fallback') % enc_name or ns
-
-
 # XEP-0203: Delayed Delivery
 
 def parse_delay(stanza, epoch=True, convert='utc', from_=None, not_from=None):
diff --git a/gajim/common/modules/util.py b/gajim/common/modules/util.py
index 7ae4b5929d337c2d520245a702c980c8520e72ef..5ff3891aaad3196df0773865e59fa78915fe1bca 100644
--- a/gajim/common/modules/util.py
+++ b/gajim/common/modules/util.py
@@ -20,6 +20,7 @@ from functools import wraps
 from functools import partial
 
 from gajim.common import app
+from gajim.common.const import EME_MESSAGES
 
 
 def from_xs_boolean(value: Union[str, bool]) -> bool:
@@ -73,3 +74,10 @@ def store_publish(func):
             return
         return func(self, *args, **kwargs)
     return func_wrapper
+
+
+def get_eme_message(eme_data):
+    try:
+        return EME_MESSAGES[eme_data.namespace]
+    except KeyError:
+        return EME_MESSAGES['fallback'] % eme_data.name
diff --git a/gajim/common/zeroconf/client_zeroconf.py b/gajim/common/zeroconf/client_zeroconf.py
index 7944d3c3aedf6d0442b3323d9214ebc2acb07db5..889f6059fcfb788a4622b4f72d6d9f69d2c83e25 100644
--- a/gajim/common/zeroconf/client_zeroconf.py
+++ b/gajim/common/zeroconf/client_zeroconf.py
@@ -28,6 +28,7 @@ from unittest.mock import Mock
 import nbxmpp
 from nbxmpp import dispatcher_nb
 from nbxmpp import simplexml
+from nbxmpp.structs import StanzaHandler
 from nbxmpp.plugin import PlugIn
 from nbxmpp.idlequeue import IdleObject
 from nbxmpp.transports_nb import DATA_RECEIVED
@@ -322,8 +323,10 @@ class P2PClient(IdleObject):
 
     def _register_handlers(self):
         self._caller.peerhost = self.Connection._sock.getsockname()
-        self.RegisterHandler('message', lambda conn,
-            data: self._caller._messageCB(self.Server, conn, data))
+
+        self.RegisterHandler(*StanzaHandler(name='message',
+                                            callback=self._caller._messageCB))
+
         self.RegisterHandler('iq', self._caller._siSetCB, 'set', nbxmpp.NS_SI)
         self.RegisterHandler('iq', self._caller._siErrorCB, 'error',
             nbxmpp.NS_SI)
diff --git a/gajim/common/zeroconf/connection_handlers_zeroconf.py b/gajim/common/zeroconf/connection_handlers_zeroconf.py
index 9c1b52f7d833a75898218b32e15345425d926448..31059c4b46d3345ba1b2c5c2e4607d52535a6155 100644
--- a/gajim/common/zeroconf/connection_handlers_zeroconf.py
+++ b/gajim/common/zeroconf/connection_handlers_zeroconf.py
@@ -27,14 +27,13 @@ import nbxmpp
 from gajim.common import app
 
 from gajim.common.protocol.bytestream import ConnectionSocks5BytestreamZeroconf
-from gajim.common.zeroconf.zeroconf import Constant
 from gajim.common import connection_handlers
 from gajim.common.i18n import _
 from gajim.common.helpers import AdditionalDataDict
 from gajim.common.nec import NetworkIncomingEvent, NetworkEvent
 from gajim.common.const import KindConstant
 from gajim.common.modules.user_nickname import parse_nickname
-from gajim.common.modules.misc import parse_eme
+from gajim.common.modules.util import get_eme_message
 from gajim.common.modules.misc import parse_correction
 from gajim.common.modules.misc import parse_attention
 from gajim.common.modules.misc import parse_oob
@@ -65,11 +64,11 @@ class ConnectionHandlersZeroconf(ConnectionSocks5BytestreamZeroconf,
         connection_handlers.ConnectionJingle.__init__(self)
         connection_handlers.ConnectionHandlersBase.__init__(self)
 
-    def _messageCB(self, ip, con, stanza):
+    def _messageCB(self, _con, stanza, properties):
         """
         Called when we receive a message
         """
-        log.debug('Zeroconf MessageCB')
+        log.info('Zeroconf MessageCB')
 
         app.nec.push_incoming_event(NetworkEvent(
             'raw-message-received',
@@ -85,13 +84,6 @@ class ConnectionHandlersZeroconf(ConnectionSocks5BytestreamZeroconf,
 
         fjid = str(stanza.getFrom())
 
-        if fjid is None:
-            for key in self.connection.zeroconf.contacts:
-                if ip == self.connection.zeroconf.contacts[key][
-                        Constant.ADDRESS]:
-                    fjid = key
-                    break
-
         jid, resource = app.get_room_and_nick_from_fjid(fjid)
 
         thread_id = stanza.getThread()
@@ -132,9 +124,8 @@ class ConnectionHandlersZeroconf(ConnectionSocks5BytestreamZeroconf,
         app.plugin_manager.extension_point(
             'decrypt', self, event, self._on_message_decrypted)
         if not event.encrypted:
-            eme = parse_eme(event.stanza)
-            if eme is not None:
-                event.msgtxt = eme
+            if properties.eme is not None:
+                event.msgtxt = get_eme_message(properties.eme)
             self._on_message_decrypted(event)
 
     def _on_message_decrypted(self, event):