diff --git a/core/client.js b/core/client.js
index 9d3c6dcb9..e71efef3e 100644
--- a/core/client.js
+++ b/core/client.js
@@ -296,10 +296,31 @@ function split(container, children) {
 	}
 }
 
+var gCorkCount = 0;
+var gCorkLines = [];
+
 function receive(data) {
 	for (var i in data.lines) {
 		var line = data.lines[i];
 
+		if (line && line[0] && line[0].action == "cork"
+			|| line && line.value && line.value[0].action == "cork") {
+			++gCorkCount;
+			continue;
+		} else if (line && line[0] && line[0].action == "uncork"
+			|| line && line.value && line.value[0].action == "uncork") {
+			if (--gCorkCount <= 0) {
+				receive({lines: gCorkLines});
+				gCorkLines.length = 0;
+			}
+			continue;
+		}
+
+		if (gCorkCount > 0) {
+			gCorkLines.push(line);
+			continue;
+		}
+
 		var target = document.getElementsByClassName("terminal")[0].id;
 		if (line && line.terminal) {
 			if (document.getElementById("terminal_" + line.terminal)) {
@@ -307,6 +328,7 @@ function receive(data) {
 			}
 			line = line.value;
 		}
+
 		if (line && line.action == "ping") {
 			gSocket.send(JSON.stringify({action: "pong"}));
 		} else if (line && line.action == "session") {
@@ -790,6 +812,9 @@ function connectSocket() {
 					['watchPosition', 'options'],
 					['clearWatch'],
 
+					['cork'],
+					['uncork'],
+
 					['setSendDeviceOrientationEvents', 'value'],
 				],
 			}));
diff --git a/core/core.js b/core/core.js
index 53bdc7b4f..73e4c912b 100644
--- a/core/core.js
+++ b/core/core.js
@@ -321,8 +321,6 @@ async function getProcess(packageOwner, packageName, key, options) {
 					'readLine': process.terminal.readLine.bind(process.terminal),
 					'setEcho': process.terminal.setEcho.bind(process.terminal),
 					'select': process.terminal.select.bind(process.terminal),
-					'cork': process.terminal.cork.bind(process.terminal),
-					'uncork': process.terminal.uncork.bind(process.terminal),
 				};
 				if (options.terminalApi) {
 					for (let i in options.terminalApi) {
@@ -391,10 +389,14 @@ function updateProcesses(packageOwner, packageName) {
 		var process = gProcesses[i];
 		if (process.packageOwner == packageOwner
 			&& process.packageName == packageName) {
-			if (process.terminal) {
-				process.terminal.notifyUpdate();
-			} else {
-				process.task.kill();
+			try {
+				if (process.terminal) {
+					process.terminal.notifyUpdate();
+				} else {
+					process.task.kill();
+				}
+			} catch (error) {
+				print(error);
 			}
 		}
 	}
diff --git a/core/terminal.js b/core/terminal.js
index 00946ca5a..d3924d7ce 100644
--- a/core/terminal.js
+++ b/core/terminal.js
@@ -21,7 +21,6 @@ function Terminal() {
 	this._echo = true;
 	this._readLine = null;
 	this._selected = null;
-	this._corked = 0;
 	this._onOutput = null;
 	return this;
 }
@@ -61,9 +60,7 @@ Terminal.prototype.print = function() {
 		this._firstLine = this._index - Terminal.kBacklog;
 		this._lines = this._lines.slice(this._lines.length - Terminal.kBacklog);
 	}
-	if (this._corked == 0) {
-		this.dispatch();
-	}
+	this.dispatch();
 	this._lastWrite = new Date();
 }
 
@@ -93,16 +90,6 @@ Terminal.prototype.readLine = function() {
 	});
 }
 
-Terminal.prototype.cork = function() {
-	this._corked++;
-}
-
-Terminal.prototype.uncork = function() {
-	if (--this._corked == 0) {
-		this.dispatch();
-	}
-}
-
 Terminal.prototype.makeFunction = function(api) {
 	let self = this;
 	return function() {