def decode(self, envelope, session, target=None, modification_code=None, **kwargs):
		""" Methods checks envelope for 'modification_code' existence and removes it.

		:param envelope: original envelope
		:param session: original session
		:param target: flag, that specifies whether code must be searched and removed at the start or at the end
		:param modification_code: code to search/remove
		:param kwargs: additional arguments

		:return: WMessengerTextEnvelope or WMessengerBytesEnvelope (depends on the original envelope)
		"""
		self.__args_check(envelope, target, modification_code)

		message = envelope.message()
		if len(message) < len(modification_code):
			raise ValueError('Invalid message length')

		if isinstance(envelope, WMessengerTextEnvelope):
			target_envelope_cls = WMessengerTextEnvelope
		else:  # isinstance(envelope, WMessengerBytesEnvelope)
			target_envelope_cls = WMessengerBytesEnvelope

		if target == WMessengerFixedModificationLayer.Target.head:
			if message[:len(modification_code)] != modification_code:
				raise ValueError('Invalid header in message')
			return target_envelope_cls(message[len(modification_code):], meta=envelope)
		else:  # target == WMessengerFixedModificationLayer.Target.tail
			if message[-len(modification_code):] != modification_code:
				raise ValueError('Invalid tail in message')
			return target_envelope_cls(message[:-len(modification_code)], meta=envelope)
Methods checks envelope for 'modification_code' existence and removes it.

		:param envelope: original envelope
		:param session: original session
		:param target: flag, that specifies whether code must be searched and removed at the start or at the end
		:param modification_code: code to search/remove
		:param kwargs: additional arguments

		:return: WMessengerTextEnvelope or WMessengerBytesEnvelope (depends on the original envelope)