Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
diff --git a/src/buffer.c b/src/buffer.c
index cf7ecbb..a6878e6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1379,12 +1379,7 @@
 #endif
 
 #ifdef FEAT_SYN_HL
-    if (curwin->w_s != &curwin->w_buffer->b_s)
-    {
-	/* Get rid of independant syntax */
-	syntax_clear(curwin->w_s);
-	vim_free(curwin->w_s);
-    }
+    reset_synblock(curwin);
     curwin->w_s = &(buf->b_s);
 #endif
     /* Get the buffer in the current window. */
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index f05a065..2ffaa3e 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3571,6 +3571,9 @@
 	    new_name = NULL;
 #endif
 	buf_freeall(curbuf, FALSE, FALSE);   /* free all things for buffer */
+#ifdef FEAT_SYN_HL
+	reset_synblock(curwin);	    /* remove any ownsyntax */
+#endif
 #ifdef FEAT_AUTOCMD
 	/* If autocommands deleted the buffer we were going to re-edit, give
 	 * up and jump to the end. */
diff --git a/src/proto/syntax.pro b/src/proto/syntax.pro
index 0e484cb..b2d63fd 100644
--- a/src/proto/syntax.pro
+++ b/src/proto/syntax.pro
@@ -6,6 +6,7 @@
 int syntax_check_changed __ARGS((linenr_T lnum));
 int get_syntax_attr __ARGS((colnr_T col, int *p_flags, int *can_spell, int keep_state));
 void syntax_clear __ARGS((synblock_T *block));
+void reset_synblock __ARGS((win_T *wp));
 void ex_syntax __ARGS((exarg_T *eap));
 void ex_ownsyntax __ARGS((exarg_T *eap));
 int syntax_present __ARGS((win_T *win));
diff --git a/src/syntax.c b/src/syntax.c
index 2b70c6d..0388209 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -3421,6 +3421,21 @@
 }
 
 /*
+ * Get rid of ownsyntax for window "wp".
+ */
+    void
+reset_synblock(wp)
+    win_T *wp;
+{
+    if (wp->w_s != &wp->w_buffer->b_s)
+    {
+	syntax_clear(wp->w_s);
+	vim_free(wp->w_s);
+	wp->w_s = &wp->w_buffer->b_s;
+    }
+}
+
+/*
  * Clear syncing info for one buffer.
  */
     static void
@@ -3538,7 +3553,6 @@
 	    if (curwin->w_s == &curwin->w_buffer->b_s)
 		do_unlet((char_u *)"b:current_syntax", TRUE);
 	    do_unlet((char_u *)"w:current_syntax", TRUE);
-
 	}
     }
     else
diff --git a/src/window.c b/src/window.c
index e878d9f..239a809 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1176,7 +1176,8 @@
 
     newp->w_buffer = oldp->w_buffer;
 #ifdef FEAT_SYN_HL
-    newp->w_s = oldp->w_s;
+    /* TODO: use reference count? */
+    newp->w_s = &(oldp->w_buffer->b_s);
 #endif
     oldp->w_buffer->b_nwindows++;
     newp->w_cursor = oldp->w_cursor;
@@ -4408,18 +4409,13 @@
 #endif /* FEAT_GUI */
 
 #ifdef FEAT_SYN_HL
-    /* free independent synblock */
-    if (wp->w_s != &wp->w_buffer->b_s)
-    {
-	syntax_clear(wp->w_s);
-	vim_free(wp->w_s);
-    }
+    reset_synblock(wp);  /* free independent synblock */
 #endif
 
 #ifdef FEAT_AUTOCMD
     if (wp != aucmd_win)
 #endif
-    win_remove(wp, tp);
+	win_remove(wp, tp);
     vim_free(wp);
 
 #ifdef FEAT_AUTOCMD