       @_setCaretToStartOf(nextNode) if nextNode
       $currentMentionNode.remove()
 
-  populateInput: =>
-    val = @serializeEditable()
-    @$input?.val(val)
-
-  serializeEditable: ->
-    @serializeNode(@$editable[0]).join('')
-
-  serializeNode: (parentNode)->
-    textNodes = []
-    for node in parentNode.childNodes
-      # is text node, append text
-      if node.nodeType == 3 # nodeType 3 is a text node
-        textNodes.push node.data
-      # is br node, append newline
-      else if node.nodeName.toUpperCase() == 'BR'
-        textNodes.push "\n"
-      # is mention, append serializedMention
-      else if serializedMention = $(node).attr('serialized-mention')
-        textNodes.push serializedMention
-      # is p or div, append newline and serialize children
-      else if node.nodeName.toUpperCase() == 'P' || node.nodeName.toUpperCase() == 'DIV'
-        # add newline only if first child is not a br-node, prevent endless new line duplicating
-        textNodes.push("\n") unless node.childNodes[0]?.nodeName?.toUpperCase() == 'BR'
-        textNodes = textNodes.concat @serializeNode(node)
-      # is any other tag, serialize children
-      else
-        textNodes = textNodes.concat @serializeNode(node)
-    textNodes
-
-  # if we remove items from nodeList it is updated live, that results in missed nodes
-  # therefore we save the node references in an array and iterate over that
-  cloneReferences = (nodes)->
-    for node in nodes
-      node
-
-  # iterate over child nodes and clean them
-  cleanChildNodes: (parentNode)->
-    for node in cloneReferences(parentNode.childNodes)
-      @cleanNode(node)
-
-    true
-
-  # clean a single node
-  # recurses into child nodes
-  # TODO keep <br>'s
-  cleanNode: (node)->
-    # dont clean text nodes or mention nodes
-    if node.nodeType == 3
-      # do nothing
-    else if node.nodeName == 'BR'
-      $(node).replaceWith(' ') unless @multiline # clean breaks in single line inputs
-    else if $(node).attr('serialized-mention')
-      $(node).attr('contenteditable', false) # ensure contenteditable is set after paste
-    else
-      # clean all children and replace node with them
-      if node.childNodes?.length > 0
-        @cleanChildNodes(node)
-        $(node).replaceWith(node.childNodes)
-      # remove node
-      else
-        $(node).remove()
-
-    true
-
-  deserializeFromInput: =>
-    @$editable.html @_deserialize(@$originalInput.val())
-
-  _deserialize: (text)->
-    result = []
-    regex = @options.deserializeRegex
-    #console.log "START", text
-    pointer = 0
-
-    # deserialize magic
-    loop
-      match = regex.exec(text)
-      if match
-        # add text before matched token
-        unless match.index == 0
-          #console.log "LOOP substring from #{pointer} to #{match.index}", text.substring(pointer, match.index)
-          @_deserializeText.call(result, text.substring(pointer, match.index))
-          #result.push document.createTextNode(text.substring(pointer, match.index))
-        pointer = regex.lastIndex
-        # deserialize matched token
-        #console.log "LOOP deserialize", match[0]
-        result.push @options.deserialize.apply(@, match)
-      else
-        unless pointer == text.length
-          #console.log "LAST substring from #{pointer} to #{text.length}", text.substring(pointer, text.length)
-          lastText = text.substring(pointer, text.length)
-          @_deserializeText.call(result, lastText) unless lastText == ''
-          #result.push document.createTextNode(lastText)  unless lastText == ''
-        break
-    # return array of nodes
-    #console.log "RESULT", result, "\n\n"
-    result
-
-  # Split text into lines and add br-nodes to keep line breaks
-  # musst be called with array as context (this), for example see _deserialize a few lines above
-  _deserializeText: (text)->
-    #console.log "_deserializeText", text
-    lines = text.split("\n")
-    for line, i in lines
-      @push document.createTextNode(line)
-      @push document.createElement('br') unless i == lines.length - 1
-
+  # Check if $.mentionsKinder is seting up to the correct element
   _ensureInput: (element)->
     @$originalInput = $(element)
     unless @$originalInput.is('input[type=text],textarea')

    else
      @abortAutocomplete()

  isAutocompleting: ->
    if @_current?
      if $.contains(@$editable, @_current.$tempMention)

###
  MentionsKinder base class
###
class MentionsKinder
  KEY = { RETURN: 13, ESC: 27 }
