diff --git a/semantics/phraseology_generator.py b/semantics/phraseology_generator.py
index f9756ac..fc63488 100644
--- a/semantics/phraseology_generator.py
+++ b/semantics/phraseology_generator.py
@@ -7,7 +7,7 @@ def lexicalisation(argument, categories, base):
     subj = is_subj(categories)
     b = argument.type
     if b == 'fixed':
-        return get_words(sortatributes(argument)[-1])
+        return (get_words(sortatributes(argument)[-1]), [])
     attributes = sortatributes(argument)
     lexicalisation_type = attributes[0].values.all()[0].argument.type
     lexicalisation_parameters = sortatributes(attributes[0].values.all()[0].argument)
@@ -21,8 +21,8 @@ def lexicalisation(argument, categories, base):
         prepnps = get_prepnps(get_preposition(lexicalisation_parameters[0]), get_case(lexicalisation_parameters[1], subj), get_number(attributes[1], subj), get_words(attributes[2]), attributes[3])
         return (prepnps, [])
     else:
-        return []
-    return []
+        return ([], [])
+    return ([], [])
 
 def is_subj(categories):
     for cat in categories:
diff --git a/semantics/saving.py b/semantics/saving.py
index e89c15b..03e8d2f 100644
--- a/semantics/saving.py
+++ b/semantics/saving.py
@@ -95,7 +95,7 @@ def make_operations(lemma_id, operations):
             else:
                 frame_id = int(operation['frame_id'])
             luids = [translation['unit_id'][int(m)] if int(m) in translation['unit_id'] else int(m) for m in operation['units']]
-            change_units(frame_id, luids)
+            change_units(lemma_id, frame_id, luids)
         elif operation['operation'] == "set_opinion":
             if int(operation['frame_id']) in translation['frame_id']:
                 frame_id = translation['frame_id'][int(operation['frame_id'])]
@@ -207,11 +207,13 @@ def validate_roles(roles):
             ok = not ok
     return ok
 
-def change_units(frame_id, luids):
+def change_units(lemma_id, frame_id, luids):
     frame = SemanticFrame.objects.get(id=frame_id)
     frame.lexical_units = []
     for id in luids:
         lu = LexicalUnit.objects.get(id=id)
+        lu.entry = Lemma.objects.get(id=lemma_id).entry_obj
+        lu.save()
         frame.lexical_units.add(lu)
         
 def set_opinion(frame_id, opinion):
diff --git a/semantics/sem_urls.py b/semantics/sem_urls.py
index 8917c2b..4c3b176 100644
--- a/semantics/sem_urls.py
+++ b/semantics/sem_urls.py
@@ -25,4 +25,5 @@ SEMANTIC_PATTERNS = patterns('semantics.views',
     url(r'^ajax/general_preference_form/$', 'general_preference_form'),
     url(r'^ajax/synset_preference_form/$', 'synset_preference_form'),
     url(r'^ajax/relational_preference_form/$', 'relational_preference_form'),
+    url(r'^ajax/get_mwe_list/$', 'ajax_get_mwes'),
 )
diff --git a/semantics/static/js/semantics_lexical_units.js b/semantics/static/js/semantics_lexical_units.js
index f69ac97..e841208 100644
--- a/semantics/static/js/semantics_lexical_units.js
+++ b/semantics/static/js/semantics_lexical_units.js
@@ -228,7 +228,8 @@ function getMeaningsSelectionForFrame(frame_id) {
 	    for (k = 0; k < schemas_content[sch].display.arguments[0].length; k++) {
 		var proper = schemas_content[sch].display.arguments[0][k].csv_id + "alt_" + sid_alt[1] + "_";
                 if (connected[lem].indexOf(proper) != -1) {
-                    if (schemas_content[sch].display.arguments[0][k].vrb.length > 0) {
+                    if (schemas_content[sch].display.arguments[0][k].vrb != null &&
+                        schemas_content[sch].display.arguments[0][k].vrb.length > 0) {
                         pre.push(schemas_content[sch].display.arguments[0][k].lex);
                         vrb = schemas_content[sch].display.arguments[0][k].vrb;
                     } else {
@@ -329,17 +330,28 @@ function lexicalisationForm(lemma, pre, tokenised) {
         list = subjUnits(pre, lemma, tokenised);
     }
 
+    $.ajax({
+        type: "GET",
+        dataType: "json",
+        url: ajax_get_mwes,
+        data: {"options": JSON.stringify(list)},
+        success: function(data){
+            list = data.mwes;
+        },
+        async: false
+    });
+
     var display = "";
     var i, j;
     for (i = 0; i < list.length; i++) {
         var included = false;
         for (j = 0; j < lexical_units.length; j++) {
-            if (list[i] == lexical_units[j].base) {
+            if (list[i].base == lexical_units[j].base) {
                 included = true;
             }
         }
         if (!included) {
-            display += "<input type = \"checkbox\" name = \"mwe\" value = \"" + list[i] + "\">" + list[i] + "<br\>";
+            display += "<input type = \"checkbox\" name = \"mwe\" value = \"" + list[i].base + list[i].sense + "_" + list[i].id + "_" + list[i].luid + "_" + list[i].sid + "\">" + list[i].base + list[i].sense + "<br\>";
         }
     }
     return display;
@@ -353,7 +365,7 @@ function noSubjUnits(lemmata, dependants) {
              result.push(lemmata[i]);
         } else {
             for (j = 0; j < dependants.length; j++) {
-                result.push(lemmata[i] + dependants[j].join(" "));
+                result.push(lemmata[i] + " " + dependants[j].join(" "));
             }
         }
     }
@@ -414,13 +426,22 @@ function addPhraseologicalUnit(mwe, glossa, relation, to) {
     return (free_luid + 1);
 }
 
-function addPhraseologicalUnits(frame_id, old_units, mwes, glossa, relation, to) {
+function unlockPhraseologicalUnit(mwe) {
+    var lu = {base: mwe.lu.split('-')[0], glossa: "", definition: "", id: mwe.id, luid: mwe.luid, refl: false, glossa: "", pos: "czasownik", sense: mwe.lu.split('-')[1], relation: 2, to: -1, location: ""};
+    lexical_units.push(lu);
+    return mwe.id;
+}
+
+function addPhraseologicalUnits(frame_id, old_units, old_mwes, new_mwes, glossa, relation, to) {
     var i;
-    var units = [];
-    for (i = 0; i < mwes.length; i++) {
-        units.push(addPhraseologicalUnit(mwes[i], glossa, relation, to));
+    var units = old_units.slice();
+    for (i = 0; i < old_mwes.length; i++) {
+        units.push(unlockPhraseologicalUnit(old_mwes[i]));
+    }
+    for (i = 0; i < new_mwes.length; i++) {
+        units.push(addPhraseologicalUnit(new_mwes[i], glossa, relation, to));
     }
-    changeUnits(frame_id, old_units.concat(units));
+    changeUnits(frame_id, units);
 }
 
 
@@ -431,7 +452,7 @@ function getPhraseologicalAlternations(frame_id) {
 	var i;
 	for (i = 0; i < connected[lem].length; i++) {
             var ids = connected[lem][i].split('_');
-            result.push(ids[1] + "_" + ids[7])
+            result.push(ids[1] + "_" + ids[7]);
 	}
     } 
     return unique(result);
diff --git a/semantics/static/js/semantics_view.js b/semantics/static/js/semantics_view.js
index 6a36f35..abd13d9 100644
--- a/semantics/static/js/semantics_view.js
+++ b/semantics/static/js/semantics_view.js
@@ -397,6 +397,8 @@ function changeLexicalUnits() {
 
     var units = [];
     var mwes = [];
+    var new_mwes = [];
+    var old_mwes = [];
     var a = "";
     var gloss = "";
 
@@ -411,7 +413,7 @@ function changeLexicalUnits() {
                     if (v == 1) {
                         changeUnits(highlighted_id, units);
 
-                        addPhraseologicalUnits(highlighted_id, units, mwes, f.glossa, f.relation, f.synset);
+                        addPhraseologicalUnits(highlighted_id, units, old_mwes, new_mwes, f.glossa, f.relation, f.synset);
 
                         frameClick("");
 		        displayFrames();
@@ -445,8 +447,46 @@ function changeLexicalUnits() {
                                 frameClick(a);
                                 $.prompt.close();
                             } else {
-                                 $.prompt.goToState('state1');
-                                 attachPlWNContextAutocomplete();
+                                 
+                                 var i;
+                                 for (i = 0; i < mwes.length; i++) {
+                                     var lu = mwes[i].split('_')[0];
+                                     var id = mwes[i].split('_')[1];
+                                     var luid = mwes[i].split('_')[2];
+                                     var sid = mwes[i].split('_')[3];
+                                     if (sid == '') {
+                                         new_mwes.push(lu);
+                                     } else {
+                                         old_mwes.push({lu: lu, id: parseInt(id), luid: parseInt(luid), sid: parseInt(sid)});
+                                     }
+                                 }
+                                 
+                                 if (old_mwes.length > 0) {
+                                     var sid = old_mwes[0].sid
+                                     var ok = true;
+                                     for (i = 0; i < old_mwes.length; i++) {
+                                         if (old_mwes[i].sid != sid) {
+                                             ok = false;
+                                         }
+                                     }
+                                     if (ok) {
+                                         changeUnits(highlighted_id, units);
+                                         
+
+                                         addPhraseologicalUnits(highlighted_id, units, old_mwes, new_mwes, old_mwes[0].lu, 1, sid);
+
+                                         frameClick("");
+                                         displayFrames();
+                                         frameClick(a);
+                                         $.prompt.close();
+                                     } else {
+                                         $.prompt.goToState('state1');
+                                         attachPlWNContextAutocomplete();
+                                     }
+                                 } else {
+                                     $.prompt.goToState('state1');
+                                     attachPlWNContextAutocomplete();
+                                 }
                             }
 
 			}
@@ -482,7 +522,7 @@ function changeLexicalUnits() {
                                 $.prompt.goToState('state2');
                             } else {
                                 /* zignorowane umiejscowienie w Słowosieci */
-                                addPhraseologicalUnits(highlighted_id, units, mwes, f.glossa, f.relation, -1);
+                                addPhraseologicalUnits(highlighted_id, units, old_mwes, new_mwes, f.glossa, f.relation, -1);
 			        frameClick("");
 			        displayFrames();
 			        frameClick(a)
diff --git a/semantics/views.py b/semantics/views.py
index 88bb335..d25d170 100644
--- a/semantics/views.py
+++ b/semantics/views.py
@@ -48,6 +48,7 @@ def ajax_semantics(request, id):
         'ajax_relations': reverse('ajax_relations'),
         'ajax_predefined_preferences': reverse('ajax_predefined_preferences'),
         'ajax_plWN_context_lookup': reverse('ajax_plWN_context_lookup'),
+        'ajax_get_mwes': reverse('ajax_get_mwes'),
     }
     return context
 
@@ -453,7 +454,8 @@ def ajax_schemas(request, lemma_id):
                 for i, c, a, p in zip(idents, schema_ids, row, ordered_positions):
                     astr, aobj = a
                     if aobj is not None and aobj.is_phraseologic():
-                        lex, vrb = lexicalisation(aobj, p.categories.all(), lemma.entry_obj.name)
+                        tmp = lexicalisation(aobj, p.categories.all(), lemma.entry_obj.name)
+                        lex, vrb = tmp
                     else:
                         lex, vrb = ([], [])
                     arg.append({"csv_id": i, "csv_class": c, "argument": astr, "lex": lex, "vrb": vrb})
@@ -643,3 +645,17 @@ def synset_preference_form(request):
 def relational_preference_form(request):
     form = RelationalSelPrefForm()
     return {'form': form}
+
+@ajax(method='get', encode_result=True)         
+def ajax_get_mwes(request, options):
+    results = []
+    for term in options:
+        term = unicode(term)
+        if len(term) > 0:
+            obj_results = LexicalUnit.objects.filter(base=term)
+            if len(obj_results) > 0:
+                for lu in obj_results:
+                    results.append({'base': lu.base, 'sense': '-' + str(lu.sense), 'id': lu.id, 'luid': lu.luid, 'sid': lu.synset.id})
+            else:
+                results.append({'base': term, 'sense': '', 'id': term, 'luid': -1, 'sid': ''})
+    return {'mwes': results}