diff --git a/src/helper/command.c b/src/helper/command.c
index d31c3588c22e8e607a2a3e99dd3eae5eb48dc5e1..31de2ec9ab8200f11580c9f388ddb904ed5e81ec 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -94,8 +94,9 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 		*retval = run_command(context, c, words, nwords);
 		
 		log_remove_callback(tcl_output, tclOutput);
-		Jim_SetResult(interp, tclOutput);
 		
+		/* We dump output into this local variable */
+		Jim_SetVariableStr(interp, "openocd_output", tclOutput);
 	}
 
 	for (i = 0; i < nwords; i++)
@@ -295,7 +296,14 @@ void command_print_n(command_context_t *context, char *format, ...)
 	string = alloc_vprintf(format, ap);
 	if (string != NULL)
 	{
-		context->output_handler(context, string);
+		/* we want this collected in the log + we also want to pick it up as a tcl return
+		 * value.
+		 * 
+		 * The latter bit isn't precisely neat, but will do for now.
+		 */
+		LOG_USER_N("%s", string);
+		// We already printed it above
+		//command_output_text(context, string);
 		free(string);
 	}
 
@@ -313,7 +321,14 @@ void command_print(command_context_t *context, char *format, ...)
 	if (string != NULL)
 	{
 		strcat(string, "\n"); /* alloc_vprintf guaranteed the buffer to be at least one char longer */
-		context->output_handler(context, string);
+		/* we want this collected in the log + we also want to pick it up as a tcl return
+		 * value.
+		 * 
+		 * The latter bit isn't precisely neat, but will do for now.
+		 */
+		LOG_USER_N("%s", string);
+		// We already printed it above
+		//command_output_text(context, string);
 		free(string);
 	}
 
@@ -369,7 +384,6 @@ int command_run_line(command_context_t *context, char *line)
 	/* run the line thru a script engine */
 	int retval;
 	int retcode;
-
 	Jim_DeleteAssocData(interp, "context"); /* remove existing */
 	retcode = Jim_SetAssocData(interp, "context", NULL, context);
 	if (retcode != JIM_OK)
@@ -382,9 +396,20 @@ int command_run_line(command_context_t *context, char *line)
 	if (retcode != JIM_OK)
 		return ERROR_FAIL;
 
+	active_cmd_ctx = context;
 	retcode = Jim_Eval(interp, line);	
 	if (retcode == JIM_ERR) {
-		Jim_PrintErrorMessage(interp);
+		if (retval!=ERROR_COMMAND_CLOSE_CONNECTION)
+		{
+			/* We do not print the connection closed error message */
+			Jim_PrintErrorMessage(interp);
+		}
+		if (retval==ERROR_OK)
+		{
+			/* It wasn't a low level OpenOCD command that failed */
+			return ERROR_FAIL; 
+		}
+		return retval;
 	} else if (retcode == JIM_EXIT) {
 		/* ignore. */
 		/* exit(Jim_GetExitCode(interp)); */
diff --git a/src/openocd.c b/src/openocd.c
index a3b0fe181eed2c088f85cc73fff8307f11a6927f..29b8d58074c98a75b28f786a1b2e62f91e4fbd06 100644
--- a/src/openocd.c
+++ b/src/openocd.c
@@ -485,59 +485,6 @@ static int Jim_Command_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *a
 }
 
 
-static int openocd_retval; 
-
-/* try to execute as Jim command, otherwise fall back to standard command.
- * Note that even if the Jim command caused an error, then we succeeded
- * to execute it, hence this fn pretty much always returns ERROR_OK. */
-int jim_command(command_context_t *context, char *line)
-{
-	int retval=ERROR_OK;
-	int retcode;
-
-	active_cmd_ctx = context;
-	openocd_retval=ERROR_OK;
-	retcode = Jim_Eval(interp, line);
-	
-	if (retcode == JIM_ERR) {
-		if (openocd_retval!=ERROR_COMMAND_CLOSE_CONNECTION)
-		{
-			/* We do not print the connection closed error message */
-			Jim_PrintErrorMessage(interp);
-		}
-		if (openocd_retval==ERROR_OK)
-		{
-			/* It wasn't a low level OpenOCD command that failed */
-			return ERROR_FAIL; 
-		}
-	    return openocd_retval;
-	} 
-	const char *result;
-	int reslen;
-	result = Jim_GetString(Jim_GetResult(interp), &reslen);
-		
-	if (retcode == JIM_EXIT) {
-		/* ignore. */
-	/* exit(Jim_GetExitCode(interp)); */
-	} else {
-		if (reslen) {
-			int i;
-			char buff[256+1];
-			for (i = 0; i < reslen; i += 256)
-			{
-				int chunk;
-				chunk = reslen - i;
-				if (chunk > 256)
-					chunk = 256;
-        		strncpy(buff, result+i, chunk);
-				buff[chunk] = 0; 
-				LOG_USER_N("%s", buff);
-			}
-			LOG_USER_N("%s", "\n");
-		}
-	}
-	return retval;
-}
 
 /* find full path to file */
 static int Jim_Command_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
diff --git a/src/startup.tcl b/src/startup.tcl
index 11ffe8515f144ac08f98331518e94d97112b1e84..fc5f9e1a0f571091fd37254bb9d661feeb8cd79c 100644
--- a/src/startup.tcl
+++ b/src/startup.tcl
@@ -95,12 +95,16 @@ add_help_text help "Tcl implementation of help command"
 
 #a bit of backwards compatibility
 proc openocd_throw {cmd} {
-	return [eval $cmd]
+	set openocd_output ""
+	eval $cmd
+	return $openocd_output
 }
 
 #a bit of backwards compatibility
 proc openocd {cmd} {
-	return [eval $cmd]
+	set openocd_output ""
+	eval $cmd
+	return $openocd_output
 }
 
 # If a fn is unknown to Tcl, we try to execute it as an OpenOCD command