diff --git a/src/debug.c b/src/debug.c
index de9350a..ca59d55 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -18,7 +18,6 @@
 
 #include "../config.h"
 #include <glib.h>
-#include <stdio.h>
 #include "debug.h"
 
 static VteDebugFlags _vte_debug_flags = 0;
diff --git a/src/iso2022.c b/src/iso2022.c
index fbc851f..a0abe26 100644
--- a/src/iso2022.c
+++ b/src/iso2022.c
@@ -19,7 +19,6 @@
 #include "../config.h"
 #include <sys/types.h>
 #include <errno.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -347,7 +346,7 @@ _vte_iso2022_ambiguous_width_guess(void)
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-		fprintf(stderr, "Ambiguous characters will have width = %d.\n",
+		g_printerr("Ambiguous characters will have width = %d.\n",
 			ret);
 	}
 #endif
@@ -772,7 +771,7 @@ _vte_iso2022_state_new(const char *nativ
 	state->target_codeset = VTE_CONV_GUNICHAR_TYPE;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-		fprintf(stderr, "Native codeset \"%s\", currently %s\n",
+		g_printerr("Native codeset \"%s\", currently %s\n",
 			state->native_codeset, state->codeset);
 	}
 #endif
@@ -785,7 +784,7 @@ #endif
 			  state->codeset, state->target_codeset);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-			fprintf(stderr, "Using UTF-8 instead.\n");
+			g_printerr("Using UTF-8 instead.\n");
 		}
 #endif
 		state->codeset = state->utf8_codeset;
@@ -836,7 +835,7 @@ _vte_iso2022_state_set_codeset(struct _v
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-		fprintf(stderr, "%s\n", codeset);
+		g_printerr("%s\n", codeset);
 	}
 #endif
 	conv = _vte_conv_open(state->target_codeset, codeset);
@@ -1196,7 +1195,7 @@ process_8_bit_sequence(struct _vte_iso20
 	if ((c == 0) && (acc != 0)) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-			fprintf(stderr, "%04lx -(%c)-> %04lx(?)\n",
+			g_printerr("%04lx -(%c)-> %04lx(?)\n",
 				acc, state->g[current] & 0xff, acc);
 		}
 #endif
@@ -1211,7 +1210,7 @@ #endif
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-			fprintf(stderr, "%05lx -> " "%04x\n", acc, c);
+			g_printerr("%05lx -> " "%04x\n", acc, c);
 		}
 #endif
 		c = _vte_iso2022_set_encoded_width(c, width);
@@ -1252,7 +1251,7 @@ process_cdata(struct _vte_iso2022_state 
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-		fprintf(stderr, "Current map = %d (%c).\n",
+		g_printerr("Current map = %d (%c).\n",
 			current, (state->g[current] & 0xff));
 	}
 #endif
@@ -1352,7 +1351,7 @@ #endif
 				if ((c == 0) && (acc != 0)) {
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-						fprintf(stderr, "%04lx -(%c)-> "
+						g_printerr("%04lx -(%c)-> "
 							"%04lx(?)\n",
 							acc,
 							state->g[current] & 0xff,
@@ -1371,7 +1370,7 @@ #endif
 					}
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-						fprintf(stderr, "%05lx -> "
+						g_printerr("%05lx -> "
 							"%04x\n", acc, c);
 					}
 #endif
@@ -1431,7 +1430,7 @@ process_control(struct _vte_iso2022_stat
 			g_array_append_val(gunichars, c);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "\tCR\n");
+				g_printerr("\tCR\n");
 			}
 #endif
 			break;
@@ -1440,7 +1439,7 @@ #endif
 			g_array_append_val(gunichars, c);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "\tLF\n");
+				g_printerr("\tLF\n");
 			}
 #endif
 			break;
@@ -1449,7 +1448,7 @@ #endif
 			state->override = -1;
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "\tSO (^N)\n");
+				g_printerr("\tSO (^N)\n");
 			}
 #endif
 			break;
@@ -1458,7 +1457,7 @@ #endif
 			state->override = -1;
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "\tSI (^O)\n");
+				g_printerr("\tSI (^O)\n");
 			}
 #endif
 			break;
@@ -1467,7 +1466,7 @@ #endif
 			state->override = 2;
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "\tSS2 (8-bit)\n");
+				g_printerr("\tSS2 (8-bit)\n");
 			}
 #endif
 			break;
@@ -1476,7 +1475,7 @@ #endif
 			state->override = 3;
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "\tSS3 (8-bit)\n");
+				g_printerr("\tSS3 (8-bit)\n");
 			}
 #endif
 			break;
@@ -1495,17 +1494,17 @@ #endif
 					}
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-						fprintf(stderr, "\t");
+						g_printerr("\t");
 						for (i = 0; i < length; i++) {
 							c = (guchar) ctl[i];
-							fprintf(stderr,
+							g_printerr(
 								"(%s%c)",
 								c < 0x20 ?
 								"^" : "",
 								c < 0x20 ?
 								c : c + 64);
 						}
-						fprintf(stderr, "\n");
+						g_printerr("\n");
 					}
 #endif
 					break;
@@ -1513,7 +1512,7 @@ #endif
 					state->override = 2;
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-						fprintf(stderr, "\tSS2\n");
+						g_printerr("\tSS2\n");
 					}
 #endif
 					break;
@@ -1521,7 +1520,7 @@ #endif
 					state->override = 3;
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-						fprintf(stderr, "\tSS3\n");
+						g_printerr("\tSS3\n");
 					}
 #endif
 					break;
@@ -1530,7 +1529,7 @@ #endif
 					state->override = -1;
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-						fprintf(stderr, "\tLS2\n");
+						g_printerr("\tLS2\n");
 					}
 #endif
 					break;
@@ -1539,7 +1538,7 @@ #endif
 					state->override = -1;
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-						fprintf(stderr, "\tLS3\n");
+						g_printerr("\tLS3\n");
 					}
 #endif
 					break;
@@ -1575,7 +1574,7 @@ #endif
 						}
 #ifdef VTE_DEBUG
 						if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-							fprintf(stderr,
+							g_printerr(
 								"\tG[%d] = %c.\n",
 								g, c);
 						}
@@ -1593,7 +1592,7 @@ #endif
 							_vte_iso2022_state_set_codeset(state, state->native_codeset);
 #ifdef VTE_DEBUG
 							if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-								fprintf(stderr,
+								g_printerr(
 									"\tNative encoding.\n");
 							}
 #endif
@@ -1605,7 +1604,7 @@ #endif
 							_vte_iso2022_state_set_codeset(state, state->utf8_codeset);
 #ifdef VTE_DEBUG
 							if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-								fprintf(stderr,
+								g_printerr(
 									"\tUTF-8 encoding.\n");
 							}
 #endif
@@ -1665,7 +1664,7 @@ #endif
 						}
 #ifdef VTE_DEBUG
 						if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-							fprintf(stderr,
+							g_printerr(
 								"\tG[%d] = wide %c.\n",
 								g, c);
 						}
@@ -1691,7 +1690,7 @@ #endif
 						}
 #ifdef VTE_DEBUG
 						if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-							fprintf(stderr,
+							g_printerr(
 								"\tG[0] = wide %c.\n",
 								c);
 						}
@@ -1733,19 +1732,19 @@ _vte_iso2022_process(struct _vte_iso2022
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
 				int j;
-				fprintf(stderr, "%3ld %3ld CDATA \"%.*s\"",
+				g_printerr("%3ld %3ld CDATA \"%.*s\"",
 					block->start, block->end,
 					(int) (block->end - block->start),
 					input->bytes + block->start);
-				fprintf(stderr, " (");
+				g_printerr(" (");
 				for (j = block->start; j < block->end; j++) {
 					if (j > block->start) {
-						fprintf(stderr, ", ");
+						g_printerr(", ");
 					}
-					fprintf(stderr, "0x%02x",
+					g_printerr("0x%02x",
 						input->bytes[j]);
 				}
-				fprintf(stderr, ")\n");
+				g_printerr(")\n");
 			}
 #endif
 			initial = 0;
@@ -1775,7 +1774,7 @@ #endif
 		case _vte_iso2022_control:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "%3ld %3ld CONTROL ",
+				g_printerr("%3ld %3ld CONTROL ",
 					block->start, block->end);
 			}
 #endif
@@ -1788,7 +1787,7 @@ #endif
 		case _vte_iso2022_preserve:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-				fprintf(stderr, "%3ld %3ld PRESERVE\n",
+				g_printerr("%3ld %3ld PRESERVE\n",
 					block->start, block->end);
 			}
 #endif
@@ -1804,7 +1803,7 @@ #endif
 		block = &g_array_index(blocks, struct _vte_iso2022_block, blocks->len - 1);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-			fprintf(stderr, "Consuming %ld bytes.\n", block->start);
+			g_printerr("Consuming %ld bytes.\n", block->start);
 		}
 #endif
 		_vte_buffer_consume(input, block->start);
@@ -1812,7 +1811,7 @@ #endif
 	} else {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-			fprintf(stderr, "Consuming %ld bytes.\n",
+			g_printerr("Consuming %ld bytes.\n",
 				(long) _vte_buffer_length(input));
 		}
 #endif
@@ -1835,6 +1834,7 @@ _vte_iso2022_unichar_width(gunichar c)
 }
 
 #ifdef ISO2022_MAIN
+#include <stdio.h>
 int
 main(int argc, char **argv)
 {
diff --git a/src/keymap.c b/src/keymap.c
index f60148a..599fcaa 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -19,7 +19,6 @@
 #include "../config.h"
 #include <stdlib.h>
 #include <stdarg.h>
-#include <stdio.h>
 #include <string.h>
 #include <glib.h>
 #include <gdk/gdk.h>
@@ -950,52 +949,52 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
-		fprintf(stderr, "Mapping ");
+		g_printerr("Mapping ");
 		if (modifiers & GDK_CONTROL_MASK) {
-			fprintf(stderr, "Control+");
+			g_printerr("Control+");
 		}
 		if (modifiers & VTE_META_MASK) {
-			fprintf(stderr, "Meta+");
+			g_printerr("Meta+");
 		}
 		if (modifiers & VTE_NUMLOCK_MASK) {
-			fprintf(stderr, "NumLock+");
+			g_printerr("NumLock+");
 		}
 		if (modifiers & GDK_SHIFT_MASK) {
-			fprintf(stderr, "Shift+");
+			g_printerr("Shift+");
 		}
-		fprintf(stderr, "%s" , _vte_keysym_name(keyval));
+		g_printerr("%s" , _vte_keysym_name(keyval));
 		if (sun_mode || hp_mode || legacy_mode || vt220_mode) {
 			i = 0;
-			fprintf(stderr, "(");
+			g_printerr("(");
 			if (sun_mode) {
 				if (i > 0) {
-					fprintf(stderr, ",");
+					g_printerr(",");
 				}
 				i++;
-				fprintf(stderr, "Sun");
+				g_printerr("Sun");
 			}
 			if (hp_mode) {
 				if (i > 0) {
-					fprintf(stderr, ",");
+					g_printerr(",");
 				}
 				i++;
-				fprintf(stderr, "HP");
+				g_printerr("HP");
 			}
 			if (legacy_mode) {
 				if (i > 0) {
-					fprintf(stderr, ",");
+					g_printerr(",");
 				}
 				i++;
-				fprintf(stderr, "Legacy");
+				g_printerr("Legacy");
 			}
 			if (vt220_mode) {
 				if (i > 0) {
-					fprintf(stderr, ",");
+					g_printerr(",");
 				}
 				i++;
-				fprintf(stderr, "VT220");
+				g_printerr("VT220");
 			}
-			fprintf(stderr, ")");
+			g_printerr(")");
 		}
 	}
 #endif
@@ -1057,7 +1056,7 @@ #endif
 	if (entries == NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
-			fprintf(stderr, " (ignoring, no map for key).\n");
+			g_printerr(" (ignoring, no map for key).\n");
 		}
 #endif
 		return;
@@ -1108,18 +1107,18 @@ #endif
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 				int j;
-				fprintf(stderr, " to '");
+				g_printerr(" to '");
 				for (j = 0; j < *normal_length; j++) {
 					if (((*normal)[j] < 32) ||
 					    ((*normal)[j] >= 127)) {
-						fprintf(stderr, "<0x%02x>",
+						g_printerr("<0x%02x>",
 							(*normal)[j]);
 					} else {
-						fprintf(stderr, "%c",
+						g_printerr("%c",
 							(*normal)[j]);
 					}
 				}
-				fprintf(stderr, "'.\n");
+				g_printerr("'.\n");
 			}
 #endif
 			return;
@@ -1135,7 +1134,7 @@ #endif
 					*special = entries[i].special;
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
-						fprintf(stderr, " to \"%s\"",
+						g_printerr(" to \"%s\"",
 							*special);
 					}
 #endif
@@ -1145,8 +1144,7 @@ #endif
 					/* Return the special string. */
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
-						fprintf(stderr,
-							", returning.\n");
+						g_printerr(", returning.\n");
 					}
 #endif
 					return;
@@ -1179,23 +1177,23 @@ #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 				int j;
 #ifdef HAVE_CURSES
-				fprintf(stderr, " via ncurses to '");
+				g_printerr(" via ncurses to '");
 #else
 #ifdef HAVE_TERMCAP
-				fprintf(stderr, " via termcap to '");
+				g_printerr(" via termcap to '");
 #endif
 #endif
 				for (j = 0; j < *normal_length; j++) {
 					if (((*normal)[j] < 32) ||
 					    ((*normal)[j] >= 127)) {
-						fprintf(stderr, "<0x%02x>",
+						g_printerr("<0x%02x>",
 							(*normal)[j]);
 					} else {
-						fprintf(stderr, "%c",
+						g_printerr("%c",
 							(*normal)[j]);
 					}
 				}
-				fprintf(stderr, "', returning.\n");
+				g_printerr("', returning.\n");
 			}
 #endif
 			return;
@@ -1205,7 +1203,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
-		fprintf(stderr, " (ignoring, no match for modifier state).\n");
+		g_printerr(" (ignoring, no match for modifier state).\n");
 	}
 #endif
 }
diff --git a/src/matcher.c b/src/matcher.c
index b664768..527b27c 100644
--- a/src/matcher.c
+++ b/src/matcher.c
@@ -19,7 +19,6 @@
 
 #include "../config.h"
 #include <sys/types.h>
-#include <stdio.h>
 #include <string.h>
 #include <glib-object.h>
 #include "debug.h"
@@ -70,7 +69,7 @@ _vte_matcher_init(struct _vte_matcher *m
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "_vte_matcher_init()\n");
+		g_printerr("_vte_matcher_init()\n");
 	}
 #endif
 
@@ -126,9 +125,9 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_TRIE)) {
-		fprintf(stderr, "Trie contents:\n");
+		g_printerr("Trie contents:\n");
 		_vte_matcher_print(matcher);
-		fprintf(stderr, "\n");
+		g_printerr("\n");
 	}
 #endif
 }
@@ -142,7 +141,7 @@ _vte_matcher_create(gpointer key)
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "_vte_matcher_create()\n");
+		g_printerr("_vte_matcher_create()\n");
 	}
 #endif
 	ret = g_slice_new(struct _vte_matcher);
@@ -178,7 +177,7 @@ _vte_matcher_destroy(gpointer value)
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "_vte_matcher_destroy()\n");
+		g_printerr("_vte_matcher_destroy()\n");
 	}
 #endif
 	if (matcher->table != NULL) {
diff --git a/src/pty.c b/src/pty.c
index d9fc7c6..1bf1247 100644
--- a/src/pty.c
+++ b/src/pty.c
@@ -334,7 +334,7 @@ #endif /* HAVE_STROPTS_H */
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_MISC) ||
 		    _vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "%ld: Set `%s'.\n", (long) getpid(),
+			g_printerr("%ld: Set `%s'.\n", (long) getpid(),
 				env_add[i]);
 		}
 #endif
@@ -358,7 +358,7 @@ #endif
 	 * on Solaris. */
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PTY)) {
-		fprintf(stderr, "Child sending child-ready.\n");
+		g_printerr("Child sending child-ready.\n");
 	}
 #endif
 	n_write(ready_writer, &c, 1);
@@ -366,7 +366,7 @@ #endif
 	n_read(ready_reader, &c, 1);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PTY)) {
-		fprintf(stderr, "Child received parent-ready.\n");
+		g_printerr("Child received parent-ready.\n");
 	}
 #endif
 	close(ready_writer);
@@ -470,19 +470,19 @@ #endif
 		 * of the terminal than just opening it. */
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Parent ready, waiting for child.\n");
+			g_printerr("Parent ready, waiting for child.\n");
 		}
 #endif
 		n_read(ready_a[0], &c, 1);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Parent received child-ready.\n");
+			g_printerr("Parent received child-ready.\n");
 		}
 #endif
 		_vte_pty_set_size(parent_fd, columns, rows);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Parent sending parent-ready.\n");
+			g_printerr("Parent sending parent-ready.\n");
 		}
 #endif
 		n_write(ready_b[1], &c, 1);
@@ -581,19 +581,19 @@ _vte_pty_fork_on_pty_fd(int fd, char **e
 		 * of the terminal than just opening it. */
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Parent ready.\n");
+			g_printerr("Parent ready.\n");
 		}
 #endif
 		n_read(ready_a[0], &c, 1);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Parent received child-ready.\n");
+			g_printerr("Parent received child-ready.\n");
 		}
 #endif
 		_vte_pty_set_size(fd, columns, rows);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Parent sending parent-ready.\n");
+			g_printerr("Parent sending parent-ready.\n");
 		}
 #endif
 		n_write(ready_b[1], &c, 1);
@@ -628,7 +628,7 @@ _vte_pty_set_size(int master, int column
 	size.ws_col = columns ? columns : 80;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PTY)) {
-		fprintf(stderr, "Setting size on fd %d to (%d,%d).\n",
+		g_printerr("Setting size on fd %d to (%d,%d).\n",
 			master, columns, rows);
 	}
 #endif
@@ -636,7 +636,7 @@ #endif
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PTY)) {
 		if (ret != 0) {
-			fprintf(stderr, "Failed to set size on %d: %s.\n",
+			g_printerr("Failed to set size on %d: %s.\n",
 				master, strerror(errno));
 		}
 	}
@@ -670,14 +670,14 @@ _vte_pty_get_size(int master, int *colum
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Size on fd %d is (%d,%d).\n",
+			g_printerr("Size on fd %d is (%d,%d).\n",
 				master, size.ws_col, size.ws_row);
 		}
 #endif
 	} else {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Failed to read size from fd %d.\n",
+			g_printerr("Failed to read size from fd %d.\n",
 				master);
 		}
 #endif
@@ -700,7 +700,7 @@ #if defined(HAVE_PTSNAME_R)
 			/* Return the allocated buffer with the name in it. */
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PTY)) {
-				fprintf(stderr, "PTY slave is `%s'.\n", buf);
+				g_printerr("PTY slave is `%s'.\n", buf);
 			}
 #endif
 			return buf;
@@ -717,7 +717,7 @@ #elif defined(HAVE_PTSNAME)
 	if ((p = ptsname(master)) != NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "PTY slave is `%s'.\n", p);
+			g_printerr("PTY slave is `%s'.\n", p);
 		}
 #endif
 		return g_strdup(p);
@@ -727,7 +727,7 @@ #elif defined(TIOCGPTN)
 	if (ioctl(master, TIOCGPTN, &pty) == 0) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "PTY slave is `/dev/pts/%d'.\n", pty);
+			g_printerr("PTY slave is `/dev/pts/%d'.\n", pty);
 		}
 #endif
 		return g_strdup_printf("/dev/pts/%d", pty);
@@ -792,7 +792,7 @@ _vte_pty_open_unix98(pid_t *child, char 
 	fd = _vte_pty_getpt();
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PTY)) {
-		fprintf(stderr, "Allocated pty on fd %d.\n", fd);
+		g_printerr("Allocated pty on fd %d.\n", fd);
 	}
 #endif
 	if (fd != -1) {
@@ -802,7 +802,7 @@ #endif
 		    (_vte_pty_unlockpt(fd) != 0)) {
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PTY)) {
-				fprintf(stderr, "PTY setup failed, bailing.\n");
+				g_printerr("PTY setup failed, bailing.\n");
 			}
 #endif
 			close(fd);
@@ -984,7 +984,7 @@ _vte_pty_open_with_helper(pid_t *child, 
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Sent request to helper.\n");
+			g_printerr("Sent request to helper.\n");
 		}
 #endif
 		/* Read back the response. */
@@ -994,7 +994,7 @@ #endif
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Received response from helper.\n");
+			g_printerr("Received response from helper.\n");
 		}
 #endif
 		if (ret == 0) {
@@ -1002,7 +1002,7 @@ #endif
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Helper returns success.\n");
+			g_printerr("Helper returns success.\n");
 		}
 #endif
 		/* Read back a tag. */
@@ -1012,7 +1012,7 @@ #endif
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Tag = %p.\n", tag);
+			g_printerr("Tag = %p.\n", tag);
 		}
 #endif
 		/* Receive the master and slave ptys. */
@@ -1026,7 +1026,7 @@ #endif
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_PTY)) {
-			fprintf(stderr, "Got master pty %d and slave pty %d.\n",
+			g_printerr("Got master pty %d and slave pty %d.\n",
 				parentfd, childfd);
 		}
 #endif
@@ -1113,7 +1113,7 @@ #endif
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PTY)) {
-		fprintf(stderr, "Returning ptyfd = %d.\n", ret);
+		g_printerr("Returning ptyfd = %d.\n", ret);
 	}
 #endif
 	return ret;
@@ -1215,10 +1215,10 @@ main(int argc, char **argv)
 			switch (i % 3) {
 			case 0:
 			case 1:
-				fprintf(stdout, "%d\n", i);
+				g_print("%d\n", i);
 				break;
 			case 2:
-				fprintf(stderr, "%d\n", i);
+				g_printerr("%d\n", i);
 				break;
 			default:
 				g_assert_not_reached();
diff --git a/src/reaper.c b/src/reaper.c
index 2e28a5f..7e95b21 100644
--- a/src/reaper.c
+++ b/src/reaper.c
@@ -79,7 +79,7 @@ vte_reaper_emit_signal(GIOChannel *chann
 	read(singleton_reaper->iopipe[0], &info, sizeof(info));
 	if (info.signum == SIGCHLD) {
 		if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-			fprintf(stderr, "Reaper emitting child-exited "
+			g_printerr("Reaper emitting child-exited "
 				"signal.\n");
 		}
 		g_signal_emit_by_name(data, "child-exited",
@@ -93,7 +93,7 @@ static void
 vte_reaper_child_watch_cb(GPid pid, gint status, gpointer data)
 {
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Reaper emitting child-exited signal.\n");
+		g_printerr("Reaper emitting child-exited signal.\n");
 	}
 	g_signal_emit_by_name(data, "child-exited", pid, status);
 }
@@ -171,7 +171,7 @@ #endif
 	action.sa_flags = SA_RESTART | SA_NOCLDSTOP;
 	sigaction(SIGCHLD, &action, NULL);
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Hooked SIGCHLD signal in reaper.\n");
+		g_printerr("Hooked SIGCHLD signal in reaper.\n");
 	}
 }
 
@@ -190,7 +190,7 @@ vte_reaper_finalize(GObject *reaper)
 		sigaction(SIGCHLD, &action, NULL);
 	}
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Unhooked SIGCHLD signal in reaper.\n");
+		g_printerr("Unhooked SIGCHLD signal in reaper.\n");
 	}
 
 	/* Remove the channel from the source list. */
diff --git a/src/reflect.c b/src/reflect.c
index 5f81af1..41b8f47 100644
--- a/src/reflect.c
+++ b/src/reflect.c
@@ -154,9 +154,9 @@ text_changed_insert(AtkObject *obj, gint
 #ifdef VTE_DEBUG
 	if ((getenv("REFLECT_VERBOSE") != NULL) &&
 	    (atol(getenv("REFLECT_VERBOSE")) != 0)) {
-		fprintf(stderr, "Inserted %d chars ('%.*s') at %d,",
+		g_printerr("Inserted %d chars ('%.*s') at %d,",
 			length, (int)(p - inserted), inserted, offset);
-		fprintf(stderr, " buffer contains %d characters.\n",
+		g_printerr(" buffer contains %d characters.\n",
 			contents->len);
 	}
 #endif
@@ -180,7 +180,7 @@ text_changed_delete(AtkObject *obj, gint
 #ifdef VTE_DEBUG
 	if ((getenv("REFLECT_VERBOSE") != NULL) &&
 	    (atol(getenv("REFLECT_VERBOSE")) != 0)) {
-		fprintf(stderr, "Deleted %d chars at %d.\n", length, offset);
+		g_printerr("Deleted %d chars at %d.\n", length, offset);
 	}
 #endif
 	update_contents(obj, GTK_WIDGET(data));
diff --git a/src/ring.c b/src/ring.c
index 3a97400..d6c9b25 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -89,8 +89,8 @@ _vte_ring_insert(VteRing * ring, long po
 	long point, i;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_RING)) {
-		fprintf(stderr, "Inserting at position %ld.\n", position);
-		fprintf(stderr, " Delta = %ld, Length = %ld, Max = %ld.\n",
+		g_printerr("Inserting at position %ld.\n", position);
+		g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
 			ring->delta, ring->length, ring->max);
 	}
 	_vte_ring_validate(ring);
@@ -107,7 +107,7 @@ #endif
 		    (ring->array[position % ring->max] != NULL)) {
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_RING)) {
-				fprintf(stderr, "Freeing item at position "
+				g_printerr("Freeing item at position "
 					"%ld.\n", position);
 			}
 #endif
@@ -126,7 +126,7 @@ #endif
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_RING)) {
-			fprintf(stderr, " Delta = %ld, Length = %ld, "
+			g_printerr(" Delta = %ld, Length = %ld, "
 				"Max = %ld.\n",
 				ring->delta, ring->length, ring->max);
 		}
@@ -149,7 +149,7 @@ #endif
 		if (ring->free && ring->array[point % ring->max]) {
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_RING)) {
-				fprintf(stderr, "Freeing item at position "
+				g_printerr("Freeing item at position "
 					"%ld.\n", point);
 			}
 #endif
@@ -173,7 +173,7 @@ #endif
 	ring->length = CLAMP(ring->length + 1, 0, ring->max);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_RING)) {
-		fprintf(stderr, " Delta = %ld, Length = %ld, Max = %ld.\n",
+		g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
 			ring->delta, ring->length, ring->max);
 	}
 	_vte_ring_validate(ring);
@@ -202,8 +202,8 @@ _vte_ring_insert_preserve(VteRing * ring
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_RING)) {
-		fprintf(stderr, "Inserting+ at position %ld.\n", position);
-		fprintf(stderr, " Delta = %ld, Length = %ld, Max = %ld.\n",
+		g_printerr("Inserting+ at position %ld.\n", position);
+		g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
 			ring->delta, ring->length, ring->max);
 	}
 	_vte_ring_validate(ring);
@@ -252,8 +252,8 @@ _vte_ring_remove(VteRing * ring, long po
 	long i;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_RING)) {
-		fprintf(stderr, "Removing item at position %ld.\n", position);
-		fprintf(stderr, " Delta = %ld, Length = %ld, Max = %ld.\n",
+		g_printerr("Removing item at position %ld.\n", position);
+		g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
 			ring->delta, ring->length, ring->max);
 	}
 	_vte_ring_validate(ring);
@@ -262,7 +262,7 @@ #endif
 	if (free && ring->array[position % ring->max] && ring->free) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_RING)) {
-			fprintf(stderr, "Freeing item at position %ld.\n",
+			g_printerr("Freeing item at position %ld.\n",
 				position);
 		}
 #endif
@@ -284,7 +284,7 @@ #endif
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_RING)) {
-		fprintf(stderr, " Delta = %ld, Length = %ld, Max = %ld.\n",
+		g_printerr(" Delta = %ld, Length = %ld, Max = %ld.\n",
 			ring->delta, ring->length, ring->max);
 	}
 	_vte_ring_validate(ring);
@@ -342,7 +342,7 @@ scrolled_off(gpointer freed, gpointer da
 {
 	long *l = (long *)freed;
 	char *fmt = data;
-	fprintf(stderr, fmt, *l);
+	g_printerr(fmt, *l);
 }
 
 int
@@ -361,10 +361,10 @@ main(int argc, char **argv)
 
 	ring = _vte_ring_new(size, scrolled_off, "Lost value %ld.\n");
 	bias = 0;
-	fprintf(stderr, "Initializing.\n");
+	g_printerr("Initializing.\n");
 	for (i = 0; i + bias <= G_N_ELEMENTS(values); i++) {
 		k = 0;
-		fprintf(stderr, "[%ld] ", i);
+		g_printerr("[%ld] ", i);
 		for (j = 0; j < G_N_ELEMENTS(values); j++) {
 			if (_vte_ring_contains(ring, j)) {
 				value = _vte_ring_index(ring, long *, j);
@@ -372,42 +372,42 @@ main(int argc, char **argv)
 				value = NULL;
 			}
 			if (value) {
-				fprintf(stderr, "%s%ld->%ld",
+				g_printerr("%s%ld->%ld",
 					(k > 0) ? ", " : "", j, *value);
 				k++;
 			}
 		}
-		fprintf(stderr, "\n");
-		fprintf(stderr, "[%ld] max %ld, delta %ld, length %ld = {",
+		g_printerr("\n");
+		g_printerr("[%ld] max %ld, delta %ld, length %ld = {",
 			i, ring->max, ring->delta, ring->length);
 		for (j = 0; j < size; j++) {
 			value = ring->array[j];
 			if (j > 0) {
-				fprintf(stderr, ", ");
+				g_printerr(", ");
 			}
 			if (value) {
-				fprintf(stderr, "%ld", *value);
+				g_printerr("%ld", *value);
 			}
 		}
-		fprintf(stderr, "}\n");
+		g_printerr("}\n");
 		if (i == 3) {
-			fprintf(stderr, "Removing item at 4.\n");
+			g_printerr("Removing item at 4.\n");
 			_vte_ring_remove(ring, 4, TRUE);
 			bias--;
 		} else if (i == 10) {
-			fprintf(stderr, "Inserting item at 7.\n");
+			g_printerr("Inserting item at 7.\n");
 			_vte_ring_insert(ring, 7, &lone);
 			bias--;
 		} else if (i == 20) {
-			fprintf(stderr, "Inserting item at 13.\n");
+			g_printerr("Inserting item at 13.\n");
 			_vte_ring_insert(ring, 13, &lone);
 			bias--;
 		} else if (i == 30) {
-			fprintf(stderr, "Inserting item at 23.\n");
+			g_printerr("Inserting item at 23.\n");
 			_vte_ring_insert_preserve(ring, 23, &lone);
 			bias--;
 		} else if (i < G_N_ELEMENTS(values)) {
-			fprintf(stderr, "Appending item.\n");
+			g_printerr("Appending item.\n");
 			_vte_ring_append(ring, &values[i + bias]);
 		}
 	}
diff --git a/src/slowcat.c b/src/slowcat.c
index 3c6aa66..df80432 100644
--- a/src/slowcat.c
+++ b/src/slowcat.c
@@ -97,7 +97,7 @@ main(int argc, char **argv)
 			}
 			break;
 		default:
-			fprintf(stderr, "Usage: slowcat [-t delay] [-c chunksize] [file ...]\n");
+			g_printerr("Usage: slowcat [-t delay] [-c chunksize] [file ...]\n");
 			exit(1);
 			break;
 		}
diff --git a/src/table.c b/src/table.c
index 370c0db..39070c3 100644
--- a/src/table.c
+++ b/src/table.c
@@ -678,7 +678,7 @@ _vte_table_printi(struct _vte_table *tab
 
 	/* Result? */
 	if (table->result != NULL) {
-		fprintf(stderr, "%s = `%s'(%d)\n", lead,
+		g_printerr("%s = `%s'(%d)\n", lead,
 			table->result, table->increment);
 	}
 
@@ -719,7 +719,7 @@ _vte_table_print(struct _vte_table *tabl
 {
 	int count = 0;
 	_vte_table_printi(table, "", &count);
-	fprintf(stderr, "%d nodes = %ld bytes.\n",
+	g_printerr("%d nodes = %ld bytes.\n",
 		count, (long) count * sizeof(struct _vte_table));
 }
 
diff --git a/src/trie.c b/src/trie.c
index 3510bb2..559eb71 100644
--- a/src/trie.c
+++ b/src/trie.c
@@ -318,7 +318,7 @@ char_class_string_extract(const gunichar
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-		fprintf(stderr, "Extracting string `%ls'.\n", (wchar_t*) ret);
+		g_printerr("Extracting string `%ls'.\n", (wchar_t*) ret);
 	}
 #endif
 	memset(&value, 0, sizeof(value));
diff --git a/src/vte.c b/src/vte.c
index 2390e9f..329d7cc 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -487,7 +487,7 @@ _vte_invalidate_cursor_once(gpointer dat
 				     row, 1);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_UPDATES)) {
-			fprintf(stderr, "Invalidating cursor at (%ld,%d-%d)."
+			g_printerr("Invalidating cursor at (%ld,%d-%d)."
 				"\n", screen->cursor_current.row,
 				column,
 				column + columns);
@@ -572,7 +572,7 @@ vte_terminal_emit_selection_changed(VteT
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `selection-changed'.\n");
+		g_printerr("Emitting `selection-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "selection-changed");
@@ -586,7 +586,7 @@ vte_terminal_emit_commit(VteTerminal *te
 	char *wrapped = NULL;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `commit' of %d bytes.\n", length);
+		g_printerr("Emitting `commit' of %d bytes.\n", length);
 	}
 #endif
 	if (length == -1) {
@@ -608,7 +608,7 @@ vte_terminal_emit_emulation_changed(VteT
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `emulation-changed'.\n");
+		g_printerr("Emitting `emulation-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "emulation-changed");
@@ -620,7 +620,7 @@ vte_terminal_emit_encoding_changed(VteTe
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `encoding-changed'.\n");
+		g_printerr("Emitting `encoding-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "encoding-changed");
@@ -632,7 +632,7 @@ vte_terminal_emit_child_exited(VteTermin
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `child-exited'.\n");
+		g_printerr("Emitting `child-exited'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "child-exited");
@@ -644,7 +644,7 @@ _vte_terminal_emit_contents_changed(VteT
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `contents-changed'.\n");
+		g_printerr("Emitting `contents-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "contents-changed");
@@ -656,7 +656,7 @@ vte_terminal_emit_cursor_moved(VteTermin
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `cursor-moved'.\n");
+		g_printerr("Emitting `cursor-moved'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "cursor-moved");
@@ -668,7 +668,7 @@ vte_terminal_emit_eof(VteTerminal *termi
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `eof'.\n");
+		g_printerr("Emitting `eof'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "eof");
@@ -681,7 +681,7 @@ vte_terminal_emit_char_size_changed(VteT
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `char-size-changed'.\n");
+		g_printerr("Emitting `char-size-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "char-size-changed",
@@ -694,7 +694,7 @@ _vte_terminal_emit_status_line_changed(V
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `status-line-changed'.\n");
+		g_printerr("Emitting `status-line-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "status-line-changed");
@@ -706,7 +706,7 @@ vte_terminal_emit_increase_font_size(Vte
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `increase-font-size'.\n");
+		g_printerr("Emitting `increase-font-size'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "increase-font-size");
@@ -718,7 +718,7 @@ vte_terminal_emit_decrease_font_size(Vte
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `decrease-font-size'.\n");
+		g_printerr("Emitting `decrease-font-size'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "decrease-font-size");
@@ -733,7 +733,7 @@ _vte_terminal_emit_text_inserted(VteTerm
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `text-inserted'.\n");
+		g_printerr("Emitting `text-inserted'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "text-inserted");
@@ -748,7 +748,7 @@ _vte_terminal_emit_text_deleted(VteTermi
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `text-deleted'.\n");
+		g_printerr("Emitting `text-deleted'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "text-deleted");
@@ -763,7 +763,7 @@ vte_terminal_emit_text_modified(VteTermi
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `text-modified'.\n");
+		g_printerr("Emitting `text-modified'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "text-modified");
@@ -778,7 +778,7 @@ vte_terminal_emit_text_scrolled(VteTermi
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `text-scrolled'(%d).\n", delta);
+		g_printerr("Emitting `text-scrolled'(%d).\n", delta);
 	}
 #endif
 	g_signal_emit_by_name(terminal, "text-scrolled", delta);
@@ -793,7 +793,7 @@ vte_terminal_deselect_all(VteTerminal *t
 		terminal->pvt->has_selection = FALSE;
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Deselecting all text.\n");
+			g_printerr("Deselecting all text.\n");
 		}
 #endif
 		vte_terminal_emit_selection_changed(terminal);
@@ -1100,7 +1100,7 @@ vte_terminal_match_check_internal(VteTer
 	struct _vte_regex_match matches[256];
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Checking for match at (%ld,%ld).\n",
+		g_printerr("Checking for match at (%ld,%ld).\n",
 			row, column);
 	}
 #endif
@@ -1133,9 +1133,9 @@ #endif
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		if (offset < 0) {
-			fprintf(stderr, "Cursor is not on a character.\n");
+			g_printerr("Cursor is not on a character.\n");
 		} else {
-			fprintf(stderr, "Cursor is on character %d.\n", offset);
+			g_printerr("Cursor is on character %d.\n", offset);
 		}
 	}
 #endif
@@ -1151,7 +1151,7 @@ #endif
 	    (terminal->pvt->match_contents[offset] == '\0')) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Cursor is on whitespace.\n");
+			g_printerr("Cursor is on whitespace.\n");
 		}
 #endif
 		terminal->pvt->match_previous = -1;
@@ -1197,7 +1197,7 @@ #ifdef VTE_DEBUG
 					eattr = &g_array_index(terminal->pvt->match_attributes,
 							       struct _VteCharAttributes,
 							       matches[j].rm_eo + coffset - 1);
-					fprintf(stderr, "Match %d `%s' from %d(%ld,%ld) to %d(%ld,%ld) (%d).\n",
+					g_printerr("Match %d `%s' from %d(%ld,%ld) to %d(%ld,%ld) (%d).\n",
 						j, match,
 						matches[j].rm_so + coffset,
 						sattr->column,
@@ -1282,7 +1282,7 @@ vte_terminal_match_check(VteTerminal *te
 	delta = terminal->pvt->screen->scroll_delta;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Checking for match at (%ld,%ld).\n",
+		g_printerr("Checking for match at (%ld,%ld).\n",
 			row, column);
 	}
 #endif
@@ -1291,7 +1291,7 @@ #endif
 						tag, NULL, NULL);
 #ifdef VTE_DEBUG
 	if ((ret != NULL) && _vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Matched `%s'.\n", ret);
+		g_printerr("Matched `%s'.\n", ret);
 	}
 #endif
 	return ret;
@@ -1306,7 +1306,7 @@ vte_terminal_emit_adjustment_changed(gpo
 	if (terminal->pvt->adjustment_changed_tag) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-			fprintf(stderr, "Emitting adjustment_changed.\n");
+			g_printerr("Emitting adjustment_changed.\n");
 		}
 #endif
 		terminal->pvt->adjustment_changed_tag = 0;
@@ -1328,7 +1328,7 @@ vte_terminal_queue_adjustment_changed(Vt
 	} else {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Swallowing duplicate "
+			g_printerr("Swallowing duplicate "
 				"adjustment-changed signal.\n");
 		}
 #endif
@@ -1356,7 +1356,7 @@ _vte_terminal_adjust_adjustments(VteTerm
 	delta = _vte_ring_delta(screen->row_data);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO)) {
-		fprintf(stderr, "Changing adjustment values "
+		g_printerr("Changing adjustment values "
 			"(delta = %ld, scroll = %ld).\n",
 			delta, screen->scroll_delta);
 	}
@@ -1364,7 +1364,7 @@ #endif
 	if (terminal->adjustment->lower != delta) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_IO)) {
-			fprintf(stderr, "Changing lower bound from %lf to %ld\n",
+			g_printerr("Changing lower bound from %lf to %ld\n",
 				terminal->adjustment->lower,
 				delta);
 
@@ -1389,7 +1389,7 @@ #endif 
 	if (terminal->adjustment->upper != rows) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_IO)) {
-			fprintf(stderr, "Changing upper bound from %f to %ld\n",
+			g_printerr("Changing upper bound from %f to %ld\n",
 				terminal->adjustment->upper,
 				rows);
 
@@ -1404,7 +1404,7 @@ #endif 
 	if (terminal->adjustment->step_increment != 1) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_IO)) {
-			fprintf(stderr, "Changing step increment from %lf to %ld\n",
+			g_printerr("Changing step increment from %lf to %ld\n",
 				terminal->adjustment->step_increment,
 				terminal->row_count);
 
@@ -1420,7 +1420,7 @@ #endif 
 	if (terminal->adjustment->page_size != terminal->row_count) {
 #ifdef VTE_DEBUG
 	      if (_vte_debug_on(VTE_DEBUG_IO)) {
-		    fprintf(stderr, "Changing page size from %f to %ld\n",
+		    g_printerr("Changing page size from %f to %ld\n",
 			    terminal->adjustment->page_size,
 			    terminal->row_count);
 
@@ -1436,7 +1436,7 @@ #endif 
 	if (terminal->adjustment->page_increment != terminal->row_count) {
 #ifdef VTE_DEBUG
 	      if (_vte_debug_on(VTE_DEBUG_IO)) {
-		    fprintf(stderr, "Changing page increment from "
+		    g_printerr("Changing page increment from "
 			    "%f to %ld\n", 
 			    terminal->adjustment->page_increment,
 			    terminal->row_count);
@@ -1453,7 +1453,7 @@ #endif 
 	    screen->scroll_delta) {
 #ifdef VTE_DEBUG
 	      if (_vte_debug_on(VTE_DEBUG_IO)) {
-		    fprintf(stderr, "Changing adjustment scroll position: "
+		    g_printerr("Changing adjustment scroll position: "
 			    "%ld\n", screen->scroll_delta);
 	      }
 #endif 
@@ -1464,7 +1464,7 @@ #endif 
 
 #ifdef VTE_DEBUG
 	      if (_vte_debug_on(VTE_DEBUG_IO)) {
-		    fprintf(stderr, "Changed adjustment scroll position: "
+		    g_printerr("Changed adjustment scroll position: "
 			    "%ld\n", screen->scroll_delta);
 	      }
 #endif 
@@ -1475,7 +1475,7 @@ #endif 
 	if (changed == TRUE) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_IO)) {
-			fprintf(stderr, "Changed adjustment values "
+			g_printerr("Changed adjustment values "
 				"(delta = %ld, scroll = %ld).\n",
 				delta, terminal->pvt->screen->scroll_delta);
 		}
@@ -1496,7 +1496,7 @@ vte_terminal_scroll_pages(VteTerminal *t
 	g_assert(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO)) {
-		fprintf(stderr, "Scrolling %d pages.\n", pages);
+		g_printerr("Scrolling %d pages.\n", pages);
 	}
 #endif
 	/* Calculate the ideal position where we want to be before clamping. */
@@ -1539,7 +1539,7 @@ vte_terminal_maybe_scroll_to_bottom(VteT
 
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_IO)) {
-		      fprintf (stderr, "Snapping to bottom of screen\n");
+		      g_printerr("Snapping to bottom of screen\n");
 		}
 #endif
 	}
@@ -1633,7 +1633,7 @@ vte_terminal_set_encoding(VteTerminal *t
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO)) {
-		fprintf(stderr, "Set terminal encoding to `%s'.\n",
+		g_printerr("Set terminal encoding to `%s'.\n",
 			terminal->pvt->encoding);
 	}
 #endif
@@ -1753,7 +1753,7 @@ _vte_terminal_set_pointer_visible(VteTer
 		    terminal->pvt->mouse_all_motion_tracking) {
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_CURSOR)) {
-				fprintf(stderr, "Setting mousing cursor.\n");
+				g_printerr("Setting mousing cursor.\n");
 			}
 #endif
 			cursor = terminal->pvt->mouse_mousing_cursor;
@@ -1767,7 +1767,7 @@ #endif
 		} else {
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_CURSOR)) {
-				fprintf(stderr, "Setting default mouse "
+				g_printerr("Setting default mouse "
 					"cursor.\n");
 			}
 #endif
@@ -1776,7 +1776,7 @@ #endif
 	} else {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_CURSOR)) {
-			fprintf(stderr, "Setting to invisible cursor.\n");
+			g_printerr("Setting to invisible cursor.\n");
 		}
 #endif
 		cursor = terminal->pvt->mouse_inviso_cursor;
@@ -1802,7 +1802,7 @@ vte_terminal_new(void)
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_new()\n");
+		g_printerr("vte_terminal_new()\n");
 	}
 #endif
 
@@ -1874,7 +1874,7 @@ vte_terminal_generate_bold(const struct 
 	b = fy + 1.722 * fcb;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Calculated bold (%d, %d, %d) = (%lf,%lf,%lf)",
+		g_printerr("Calculated bold (%d, %d, %d) = (%lf,%lf,%lf)",
 			foreground->red, foreground->green, foreground->blue,
 			r, g, b);
 	}
@@ -1884,7 +1884,7 @@ #endif
 	bold->blue = CLAMP(b, 0, 0xffff);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "= (%04x,%04x,%04x).\n",
+		g_printerr("= (%04x,%04x,%04x).\n",
 			bold->red, bold->green, bold->blue);
 	}
 #endif
@@ -2189,7 +2189,7 @@ _vte_terminal_insert_char(VteTerminal *t
 	if (screen->defaults.alternate) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SUBSTITUTION)) {
-			fprintf(stderr, "Attempting charset substitution"
+			g_printerr("Attempting charset substitution"
 				"for 0x%04x.\n", c);
 		}
 #endif
@@ -2224,7 +2224,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO) && _vte_debug_on(VTE_DEBUG_PARSE)) {
-		fprintf(stderr, "Inserting %ld %c (%d/%d)(%d), delta = %ld, ",
+		g_printerr("Inserting %ld %c (%d/%d)(%d), delta = %ld, ",
 			(long)c,
 			c < 256 ? c : ' ',
 			screen->defaults.fore, screen->defaults.back,
@@ -2385,7 +2385,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO) && _vte_debug_on(VTE_DEBUG_PARSE)) {
-		fprintf(stderr, "insertion delta => %ld.\n",
+		g_printerr("insertion delta => %ld.\n",
 			(long)screen->insert_delta);
 	}
 #endif
@@ -2403,28 +2403,28 @@ display_control_sequence(const char *nam
 	const char *s;
 	const gunichar *w;
 	GValue *value;
-	fprintf(stderr, "%s(", name);
+	g_printerr("%s(", name);
 	if (params != NULL) {
 		for (i = 0; i < params->n_values; i++) {
 			value = g_value_array_get_nth(params, i);
 			if (i > 0) {
-				fprintf(stderr, ", ");
+				g_printerr(", ");
 			}
 			if (G_VALUE_HOLDS_LONG(value)) {
 				l = g_value_get_long(value);
-				fprintf(stderr, "%ld", l);
+				g_printerr("%ld", l);
 			} else
 			if (G_VALUE_HOLDS_STRING(value)) {
 				s = g_value_get_string(value);
-				fprintf(stderr, "\"%s\"", s);
+				g_printerr("\"%s\"", s);
 			} else
 			if (G_VALUE_HOLDS_POINTER(value)) {
 				w = g_value_get_pointer(value);
-				fprintf(stderr, "\"%ls\"", (const wchar_t*) w);
+				g_printerr("\"%ls\"", (const wchar_t*) w);
 			}
 		}
 	}
-	fprintf(stderr, ")\n");
+	g_printerr(")\n");
 }
 #endif
 
@@ -2748,8 +2748,7 @@ vte_terminal_fork_command(VteTerminal *t
 				terminal->pvt->shell = pwd->pw_shell;
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_MISC)) {
-					fprintf(stderr,
-						"Using user's shell (%s).\n",
+					g_printerr("Using user's shell (%s).\n",
 						terminal->pvt->shell);
 				}
 #endif
@@ -2760,7 +2759,7 @@ #endif
 				terminal->pvt->shell = getenv ("SHELL");
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_MISC)) {
-					fprintf(stderr, "Using $SHELL shell (%s).\n",
+					g_printerr("Using $SHELL shell (%s).\n",
 						terminal->pvt->shell);
 				}
 #endif
@@ -2768,7 +2767,7 @@ #endif
 				terminal->pvt->shell = "/bin/sh";
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_MISC)) {
-					fprintf(stderr, "Using default shell (%s).\n",
+					g_printerr("Using default shell (%s).\n",
 						terminal->pvt->shell);
 				}
 #endif
@@ -2911,7 +2910,7 @@ vte_terminal_emit_pending_text_signals(V
 	if (terminal->pvt->text_modified_flag) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-			fprintf(stderr, "Emitting buffered `text-modified'.\n");
+			g_printerr("Emitting buffered `text-modified'.\n");
 		}
 #endif
 		vte_terminal_emit_text_modified(terminal);
@@ -2920,7 +2919,7 @@ #endif
 	if (terminal->pvt->text_inserted_count) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-			fprintf(stderr, "Emitting buffered `text-inserted' "
+			g_printerr("Emitting buffered `text-inserted' "
 				"(%ld).\n", terminal->pvt->text_inserted_count);
 		}
 #endif
@@ -2930,7 +2929,7 @@ #endif
 	if (terminal->pvt->text_deleted_count) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-			fprintf(stderr, "Emitting buffered `text-deleted' "
+			g_printerr("Emitting buffered `text-deleted' "
 				"(%ld).\n", terminal->pvt->text_deleted_count);
 		}
 #endif
@@ -2968,7 +2967,7 @@ vte_terminal_process_incoming(VteTermina
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO)) {
-		fprintf(stderr, "Handler processing %d bytes.\n",
+		g_printerr("Handler processing %d bytes.\n",
 			_vte_buffer_length(terminal->pvt->incoming));
 	}
 #endif
@@ -3112,17 +3111,17 @@ #ifdef VTE_DEBUG
 			c = c & ~VTE_ISO2022_ENCODED_WIDTH_MASK;
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
 				if (c > 255) {
-					fprintf(stderr, "U+%04lx\n", (long) c);
+					g_printerr("U+%04lx\n", (long) c);
 				} else {
 					if (c > 127) {
-						fprintf(stderr, "%ld = ",
+						g_printerr("%ld = ",
 							(long) c);
 					}
 					if (c < 32) {
-						fprintf(stderr, "^%lc\n",
+						g_printerr("^%lc\n",
 							(wint_t)c + 64);
 					} else {
-						fprintf(stderr, "`%lc'\n",
+						g_printerr("`%lc'\n",
 							(wint_t)c);
 					}
 				}
@@ -3161,7 +3160,7 @@ #endif
 			if (wbuf + wcount > next) {
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-					fprintf(stderr, "Invalid control "
+					g_printerr("Invalid control "
 						"sequence, discarding %d "
 						"characters.\n",
 						next - (wbuf + start));
@@ -3291,7 +3290,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO)) {
-		fprintf(stderr, "%ld chars and %ld bytes left to process.\n",
+		g_printerr("%ld chars and %ld bytes left to process.\n",
 			(long) unichars->len,
 			(long) _vte_buffer_length(terminal->pvt->incoming));
 	}
@@ -3431,7 +3430,7 @@ #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_IO)) {
 			int i;
 			for (i = 0; i < count; i++) {
-				fprintf(stderr, "Wrote %c%c\n",
+				g_printerr("Wrote %c%c\n",
 					((guint8)terminal->pvt->outgoing->bytes[i]) >= 32 ?
 					' ' : '^',
 					((guint8)terminal->pvt->outgoing->bytes[i]) >= 32 ?
@@ -3549,12 +3548,12 @@ #ifdef VTE_DEBUG
 				for (i = 0; i < cooked_length; i++) {
 					if ((((guint8) cooked[i]) < 32) ||
 					    (((guint8) cooked[i]) > 127)) {
-						fprintf(stderr,
+						g_printerr(
 							"Sending <%02x> "
 							"to child.\n",
 							cooked[i]);
 					} else {
-						fprintf(stderr,
+						g_printerr(
 							"Sending '%c' "
 							"to child.\n",
 							cooked[i]);
@@ -3652,7 +3651,7 @@ vte_terminal_im_commit(GtkIMContext *im_
 	g_assert(GTK_IS_IM_CONTEXT(im_context));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Input method committed `%s'.\n", text);
+		g_printerr("Input method committed `%s'.\n", text);
 	}
 #endif
 	terminal = VTE_TERMINAL(data);
@@ -3676,7 +3675,7 @@ vte_terminal_im_preedit_start(GtkIMConte
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Input method pre-edit started.\n");
+		g_printerr("Input method pre-edit started.\n");
 	}
 #endif
 	terminal->pvt->im_preedit_active = TRUE;
@@ -3694,7 +3693,7 @@ vte_terminal_im_preedit_end(GtkIMContext
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Input method pre-edit ended.\n");
+		g_printerr("Input method pre-edit ended.\n");
 	}
 #endif
 	terminal->pvt->im_preedit_active = FALSE;
@@ -3716,7 +3715,7 @@ vte_terminal_im_preedit_changed(GtkIMCon
 	gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Input method pre-edit changed (%s,%d).\n",
+		g_printerr("Input method pre-edit changed (%s,%d).\n",
 			str, cursor);
 	}
 #endif
@@ -3749,7 +3748,7 @@ vte_terminal_configure_toplevel(GtkWidge
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Top level parent configured.\n");
+		g_printerr("Top level parent configured.\n");
 	}
 #endif
 	g_assert(GTK_IS_WIDGET(widget));
@@ -3777,7 +3776,7 @@ vte_terminal_hierarchy_changed(GtkWidget
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Hierarchy changed.\n");
+		g_printerr("Hierarchy changed.\n");
 	}
 #endif
 
@@ -3807,7 +3806,7 @@ vte_terminal_style_changed(GtkWidget *wi
 	if (!GTK_WIDGET_REALIZED(widget)) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_MISC)) {
-			fprintf(stderr, "Don't change style if we aren't realized.\n");
+			g_printerr("Don't change style if we aren't realized.\n");
 		}
 #endif
 		return;
@@ -3932,7 +3931,7 @@ vte_terminal_key_press(GtkWidget *widget
 
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Keypress, modifiers=0x%x, "
+			g_printerr("Keypress, modifiers=0x%x, "
 				"keyval=0x%x, raw string=`%s'.\n",
 				terminal->pvt->modifiers,
 				keyval, event->string);
@@ -3992,7 +3991,7 @@ #endif
 						   event)) {
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-				fprintf(stderr, "Keypress taken by IM.\n");
+				g_printerr("Keypress taken by IM.\n");
 			}
 #endif
 			return TRUE;
@@ -4184,7 +4183,7 @@ #endif
 			}
 #ifdef VTE_DEBUG
 			if (normal && _vte_debug_on(VTE_DEBUG_EVENTS)) {
-				fprintf(stderr, "Keypress, modifiers=0x%x, "
+				g_printerr("Keypress, modifiers=0x%x, "
 					"keyval=0x%x, cooked string=`%s'.\n",
 					terminal->pvt->modifiers,
 					keyval, normal);
@@ -4444,7 +4443,7 @@ vte_terminal_paste_cb(GtkClipboard *clip
 	if (text != NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Pasting %d UTF-8 bytes.\n",
+			g_printerr("Pasting %d UTF-8 bytes.\n",
 				strlen(text));
 		}
 #endif
@@ -4668,7 +4667,7 @@ vte_terminal_match_hilite_clear(VteTermi
 	if ((srow < erow) || ((srow == erow) && (scolumn < ecolumn))) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Repainting (%ld,%ld) to (%ld,%ld).\n",
+			g_printerr("Repainting (%ld,%ld) to (%ld,%ld).\n",
 				srow, scolumn, erow, ecolumn);
 		}
 #endif
@@ -4713,7 +4712,7 @@ vte_terminal_match_hilite(VteTerminal *t
 	if (match == NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "No matches.\n");
+			g_printerr("No matches.\n");
 		}
 #endif
 		vte_terminal_match_hilite_clear(terminal);
@@ -4741,7 +4740,7 @@ #endif
 				     terminal->pvt->match_start.row + 1);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Matched (%ld,%ld) to (%ld,%ld).\n",
+			g_printerr("Matched (%ld,%ld) to (%ld,%ld).\n",
 				terminal->pvt->match_start.column,
 				terminal->pvt->match_start.row,
 				terminal->pvt->match_end.column,
@@ -4766,7 +4765,7 @@ vte_terminal_clear_cb(GtkClipboard *clip
 	if (terminal->pvt->has_selection) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Lost selection.\n");
+			g_printerr("Lost selection.\n");
 		}
 #endif
 		vte_terminal_deselect_all(terminal);
@@ -4785,10 +4784,10 @@ vte_terminal_copy_cb(GtkClipboard *clipb
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
 			int i;
-			fprintf(stderr, "Setting selection (%d UTF-8 bytes.)\n",
+			g_printerr("Setting selection (%d UTF-8 bytes.)\n",
 				strlen(terminal->pvt->selection));
 			for (i = 0; terminal->pvt->selection[i] != '\0'; i++) {
-				fprintf(stderr, "0x%04x\n",
+				g_printerr("0x%04x\n",
 					terminal->pvt->selection[i]);
 			}
 		}
@@ -5145,7 +5144,7 @@ vte_terminal_copy(VteTerminal *terminal,
 	if (terminal->pvt->selection != NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Assuming ownership of selection.\n");
+			g_printerr("Assuming ownership of selection.\n");
 		}
 #endif
 		if (!targets) {
@@ -5185,7 +5184,7 @@ vte_terminal_paste(VteTerminal *terminal
 	if (clipboard != NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Requesting clipboard contents.\n");
+			g_printerr("Requesting clipboard contents.\n");
 		}
 #endif
 		gtk_clipboard_request_text(clipboard,
@@ -5248,7 +5247,7 @@ vte_terminal_start_selection(VteTerminal
 			     terminal->pvt->selection_start.y, 1);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-		fprintf(stderr, "Selection started at (%ld,%ld).\n",
+		g_printerr("Selection started at (%ld,%ld).\n",
 			terminal->pvt->selection_start.x,
 			terminal->pvt->selection_start.y);
 	}
@@ -5291,7 +5290,7 @@ vte_terminal_extend_selection(VteTermina
 			terminal->pvt->selection_restart_origin;
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Selection delayed start at (%lf,%lf).\n",
+			g_printerr("Selection delayed start at (%lf,%lf).\n",
 				terminal->pvt->selection_origin.x / width,
 				terminal->pvt->selection_origin.y / height);
 		}
@@ -5343,7 +5342,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-		fprintf(stderr, "Selection is (%lf,%lf) to (%lf,%lf).\n",
+		g_printerr("Selection is (%lf,%lf) to (%lf,%lf).\n",
 			start->x, start->y, end->x, end->y);
 	}
 #endif
@@ -5589,7 +5588,7 @@ #endif
 	    (old_start.y != terminal->pvt->selection_start.y))) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Refreshing lines %ld to %ld.\n",
+			g_printerr("Refreshing lines %ld to %ld.\n",
 				MIN(old_start.y,
 				    terminal->pvt->selection_start.y),
 				MAX(old_start.y,
@@ -5611,7 +5610,7 @@ #endif
 	    (old_end.y != terminal->pvt->selection_end.y))) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Refreshing lines %ld to %ld.\n",
+			g_printerr("Refreshing lines %ld to %ld.\n",
 				MIN(old_end.y, terminal->pvt->selection_end.y),
 				MAX(old_end.y, terminal->pvt->selection_end.y));
 		}
@@ -5629,7 +5628,7 @@ #endif
 	if (invalidate_selected) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-			fprintf(stderr, "Refreshing lines %ld to %ld.\n",
+			g_printerr("Refreshing lines %ld to %ld.\n",
 				MIN(terminal->pvt->selection_start.y,
 				    terminal->pvt->selection_end.y),
 				MAX(terminal->pvt->selection_start.y,
@@ -5649,7 +5648,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-		fprintf(stderr, "Selection changed to "
+		g_printerr("Selection changed to "
 			"(%ld,%ld) to (%ld,%ld).\n",
 			terminal->pvt->selection_start.x,
 			terminal->pvt->selection_start.y,
@@ -5686,7 +5685,7 @@ vte_terminal_autoscroll(gpointer data)
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Autoscrolling down.\n");
+			g_printerr("Autoscrolling down.\n");
 		}
 #endif
 	}
@@ -5703,7 +5702,7 @@ #endif
 		}
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Autoscrolling up.\n");
+			g_printerr("Autoscrolling up.\n");
 		}
 #endif
 	}
@@ -5774,7 +5773,7 @@ vte_terminal_motion_notify(GtkWidget *wi
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Motion notify (%lf,%lf).\n",
+		g_printerr("Motion notify (%lf,%lf).\n",
 			event->x, event->y);
 	}
 #endif
@@ -5793,7 +5792,7 @@ #endif
 		case 1:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-				fprintf(stderr, "Mousing drag 1.\n");
+				g_printerr("Mousing drag 1.\n");
 			}
 #endif
 			/* If user hit ctrl, change selection mode. */
@@ -5895,7 +5894,7 @@ vte_terminal_button_press(GtkWidget *wid
 	case GDK_BUTTON_PRESS:
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Button %d single-click at (%lf,%lf)\n",
+			g_printerr("Button %d single-click at (%lf,%lf)\n",
 				event->button,
 				event->x - VTE_PAD_WIDTH,
 				event->y - VTE_PAD_WIDTH +
@@ -5907,7 +5906,7 @@ #endif
 		case 1:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-				fprintf(stderr, "Handling click ourselves.\n");
+				g_printerr("Handling click ourselves.\n");
 			}
 #endif
 			/* Grab focus. */
@@ -5982,7 +5981,7 @@ #endif
 	case GDK_2BUTTON_PRESS:
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Button %d double-click at (%lf,%lf)\n",
+			g_printerr("Button %d double-click at (%lf,%lf)\n",
 				event->button,
 				event->x - VTE_PAD_WIDTH,
 				event->y - VTE_PAD_WIDTH +
@@ -6011,7 +6010,7 @@ #endif
 	case GDK_3BUTTON_PRESS:
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Button %d triple-click at (%lf,%lf).\n",
+			g_printerr("Button %d triple-click at (%lf,%lf).\n",
 				event->button,
 				event->x - VTE_PAD_WIDTH,
 				event->y - VTE_PAD_WIDTH +
@@ -6084,7 +6083,7 @@ vte_terminal_button_release(GtkWidget *w
 	case GDK_BUTTON_RELEASE:
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Button %d released at (%lf,%lf).\n",
+			g_printerr("Button %d released at (%lf,%lf).\n",
 				event->button,
 				event->x - VTE_PAD_WIDTH,
 				event->y - VTE_PAD_WIDTH);
@@ -6149,7 +6148,7 @@ vte_terminal_focus_in(GtkWidget *widget,
 	g_assert(VTE_IS_TERMINAL(widget));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Focus in.\n");
+		g_printerr("Focus in.\n");
 	}
 #endif
 	terminal = VTE_TERMINAL(widget);
@@ -6184,7 +6183,7 @@ vte_terminal_focus_out(GtkWidget *widget
 	g_assert(VTE_IS_TERMINAL(widget));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Focus out.\n");
+		g_printerr("Focus out.\n");
 	}
 #endif
 	terminal = VTE_TERMINAL(widget);
@@ -6301,7 +6300,7 @@ #ifdef VTE_DEBUG
 			if (desc) {
 				char *tmp;
 				tmp = pango_font_description_to_string(desc);
-				fprintf(stderr, "Using pango font \"%s\".\n", tmp);
+				g_printerr("Using pango font \"%s\".\n", tmp);
 				g_free (tmp);
 			}
 		}
@@ -6313,7 +6312,7 @@ #endif
 
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_MISC)) {
-			fprintf(stderr, "Using default monospace font.\n");
+			g_printerr("Using default monospace font.\n");
 		}
 #endif
 	}
@@ -6452,7 +6451,7 @@ vte_terminal_set_size(VteTerminal *termi
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Setting PTY size to %ldx%ld.\n",
+		g_printerr("Setting PTY size to %ldx%ld.\n",
 			columns, rows);
 	}
 #endif
@@ -6501,7 +6500,7 @@ vte_terminal_handle_scroll(VteTerminal *
 	if (dy != 0) {
 #ifdef VTE_DEBUG
 	      if (_vte_debug_on(VTE_DEBUG_IO)) {
-		    fprintf(stderr, "Scrolling by %ld\n", dy);
+		    g_printerr("Scrolling by %ld\n", dy);
 	      }
 #endif
 		_vte_terminal_match_contents_clear(terminal);
@@ -6512,7 +6511,7 @@ #endif
 	}
 #ifdef VTE_DEBUG
 	else if (_vte_debug_on(VTE_DEBUG_IO)) {
-	      fprintf(stderr, "Not scrolling\n");
+	      g_printerr("Not scrolling\n");
 	}
 #endif
 
@@ -6572,7 +6571,7 @@ vte_terminal_set_emulation(VteTerminal *
 	terminal->pvt->emulation = g_quark_to_string(quark);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Setting emulation to `%s'...", emulation);
+		g_printerr("Setting emulation to `%s'...", emulation);
 	}
 #endif
 	/* Find and read the right termcap file. */
@@ -6675,7 +6674,7 @@ vte_terminal_set_termcap(VteTerminal *te
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Loading termcap `%s'...",
+		g_printerr("Loading termcap `%s'...",
 			terminal->pvt->termcap_path);
 	}
 #endif
@@ -6685,7 +6684,7 @@ #endif
 	terminal->pvt->termcap = _vte_termcap_new(terminal->pvt->termcap_path);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "\n");
+		g_printerr("\n");
 	}
 #endif
 	if (reset) {
@@ -6702,7 +6701,7 @@ vte_terminal_reset_rowdata(VteRing **rin
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Sizing scrollback buffer to %ld lines.\n",
+		g_printerr("Sizing scrollback buffer to %ld lines.\n",
 			lines);
 	}
 #endif
@@ -6731,7 +6730,7 @@ vte_terminal_fc_settings_changed(GtkSett
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Fontconfig setting \"%s\" changed.\n",
+		g_printerr("Fontconfig setting \"%s\" changed.\n",
 			spec->name);
 	}
 #endif
@@ -6823,7 +6822,7 @@ vte_terminal_init(VteTerminal *terminal,
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_init()\n");
+		g_printerr("vte_terminal_init()\n");
 	}
 #endif
 
@@ -6980,7 +6979,7 @@ vte_terminal_size_request(GtkWidget *wid
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_size_request()\n");
+		g_printerr("vte_terminal_size_request()\n");
 	}
 #endif
 
@@ -7006,7 +7005,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Size request is %dx%d.\n",
+		g_printerr("Size request is %dx%d.\n",
 			requisition->width, requisition->height);
 	}
 #endif
@@ -7023,7 +7022,7 @@ vte_terminal_size_allocate(GtkWidget *wi
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_size_allocate()\n");
+		g_printerr("vte_terminal_size_allocate()\n");
 	}
 #endif
 
@@ -7042,7 +7041,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Sizing window to %dx%d (%ldx%ld).\n",
+		g_printerr("Sizing window to %dx%d (%ldx%ld).\n",
 			allocation->width, allocation->height,
 			width, height);
 	}
@@ -7107,7 +7106,7 @@ vte_terminal_show(GtkWidget *widget)
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_show()\n");
+		g_printerr("vte_terminal_show()\n");
 	}
 #endif
 
@@ -7148,7 +7147,7 @@ vte_terminal_unrealize(GtkWidget *widget
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_unrealize()\n");
+		g_printerr("vte_terminal_unrealize()\n");
 	}
 #endif
 
@@ -7251,7 +7250,7 @@ vte_terminal_finalize(GObject *object)
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_finalize()\n");
+		g_printerr("vte_terminal_finalize()\n");
 	}
 #endif
 
@@ -7492,7 +7491,7 @@ vte_terminal_realize(GtkWidget *widget)
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_realize()\n");
+		g_printerr("vte_terminal_realize()\n");
 	}
 #endif
 
@@ -8604,14 +8603,14 @@ vte_terminal_draw_cells(VteTerminal *ter
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC) && 0) {
-		fprintf(stderr, "Rendering");
+		g_printerr("Rendering");
 		for (i = 0; i < n; i++) {
-			fprintf(stderr, " (%ld,%ld)",
+			g_printerr(" (%ld,%ld)",
 				(long) items[i].c,
 				(long) items[i].columns);
 			g_assert(items[i].columns > 0);
 		}
-		fprintf(stderr, ".\n");
+		g_printerr(".\n");
 	}
 #endif
 
@@ -8722,7 +8721,7 @@ _vte_terminal_map_pango_color(VteTermina
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_UPDATES)) {
-		fprintf(stderr, "mapped PangoColor(%04x,%04x,%04x) to "
+		g_printerr("mapped PangoColor(%04x,%04x,%04x) to "
 			"palette entry (%04x,%04x,%04x)\n",
 			color->red, color->green, color->blue,
 			terminal->pvt->palette[ret].red,
@@ -9125,7 +9124,7 @@ vte_terminal_paint(GtkWidget *widget, Gd
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_paint()\n");
+		g_printerr("vte_terminal_paint()\n");
 	}
 #endif
 
@@ -9451,10 +9450,10 @@ #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		switch (event->direction) {
 		case GDK_SCROLL_UP:
-			fprintf(stderr, "Scroll up.\n");
+			g_printerr("Scroll up.\n");
 			break;
 		case GDK_SCROLL_DOWN:
-			fprintf(stderr, "Scroll down.\n");
+			g_printerr("Scroll down.\n");
 			break;
 		default:
 			break;
@@ -9569,7 +9568,7 @@ vte_terminal_class_init(VteTerminalClass
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-		fprintf(stderr, "vte_terminal_class_init()\n");
+		g_printerr("vte_terminal_class_init()\n");
 	}
 #endif
 
@@ -9949,7 +9948,7 @@ vte_terminal_get_type(void)
 	if (terminal_type == 0) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
-			fprintf(stderr, "vte_terminal_get_type()\n");
+			g_printerr("vte_terminal_get_type()\n");
 		}
 #endif
 		terminal_type = g_type_register_static(GTK_TYPE_WIDGET,
@@ -10125,7 +10124,7 @@ vte_terminal_copy_clipboard(VteTerminal 
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-		fprintf(stderr, "Copying to CLIPBOARD.\n");
+		g_printerr("Copying to CLIPBOARD.\n");
 	}
 #endif
 	if (terminal->pvt->selection != NULL) {
@@ -10151,7 +10150,7 @@ vte_terminal_paste_clipboard(VteTerminal
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-		fprintf(stderr, "Pasting CLIPBOARD.\n");
+		g_printerr("Pasting CLIPBOARD.\n");
 	}
 #endif
 	vte_terminal_paste(terminal, GDK_SELECTION_CLIPBOARD);
@@ -10171,7 +10170,7 @@ vte_terminal_copy_primary(VteTerminal *t
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-		fprintf(stderr, "Copying to PRIMARY.\n");
+		g_printerr("Copying to PRIMARY.\n");
 	}
 #endif
 	vte_terminal_copy(terminal, GDK_SELECTION_PRIMARY);
@@ -10194,7 +10193,7 @@ vte_terminal_paste_primary(VteTerminal *
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
-		fprintf(stderr, "Pasting PRIMARY.\n");
+		g_printerr("Pasting PRIMARY.\n");
 	}
 #endif
 	vte_terminal_paste(terminal, GDK_SELECTION_PRIMARY);
@@ -10239,7 +10238,7 @@ vte_terminal_background_update(gpointer 
 	if (!GTK_WIDGET_REALIZED(widget)) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_MISC)) {
-			fprintf(stderr, "Can not set background image without "
+			g_printerr("Can not set background image without "
 				"window.\n");
 		}
 #endif
@@ -10248,7 +10247,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC) || _vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Updating background image.\n");
+		g_printerr("Updating background image.\n");
 	}
 #endif
 
@@ -10331,13 +10330,13 @@ vte_terminal_queue_background_update(Vte
 						NULL);
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Queued background update.\n");
+			g_printerr("Queued background update.\n");
 		}
 #endif
 	} else {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
-			fprintf(stderr, "Skipping background update.\n");
+			g_printerr("Skipping background update.\n");
 		}
 #endif
 	}
@@ -10365,7 +10364,7 @@ vte_terminal_set_background_saturation(V
 					     0, VTE_SATURATION_MAX);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Setting background saturation to %ld/%ld.\n",
+		g_printerr("Setting background saturation to %ld/%ld.\n",
 			terminal->pvt->bg_saturation,
 			(long) VTE_SATURATION_MAX);
 	}
@@ -10401,7 +10400,7 @@ vte_terminal_set_background_tint_color(V
 	terminal->pvt->bg_tint_color = *color;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Setting background tint to %d,%d,%d.\n",
+		g_printerr("Setting background tint to %d,%d,%d.\n",
 			terminal->pvt->bg_tint_color.red >> 8,
 			terminal->pvt->bg_tint_color.green >> 8,
 			terminal->pvt->bg_tint_color.blue >> 8);
@@ -10427,7 +10426,7 @@ vte_terminal_set_background_transparent(
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Turning background transparency %s.\n",
+		g_printerr("Turning background transparency %s.\n",
 			transparent ? "on" : "off");
 	}
 #endif
@@ -10458,7 +10457,7 @@ vte_terminal_set_background_image(VteTer
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "%s background image.\n",
+		g_printerr("%s background image.\n",
 			GDK_IS_PIXBUF(image) ? "Setting" : "Clearing");
 	}
 #endif
@@ -10502,7 +10501,7 @@ vte_terminal_set_background_image_file(V
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Loading background image from `%s'.\n", path);
+		g_printerr("Loading background image from `%s'.\n", path);
 	}
 #endif
 	/* Save this background type. */
@@ -10711,7 +10710,7 @@ vte_terminal_set_word_chars(VteTerminal 
 			g_array_append_val(terminal->pvt->word_chars, range);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_MISC)) {
-				fprintf(stderr, "Word charset includes hyphen.\n");
+				g_printerr("Word charset includes hyphen.\n");
 			}
 #endif
 			continue;
@@ -10723,7 +10722,7 @@ #endif
 			g_array_append_val(terminal->pvt->word_chars, range);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_MISC)) {
-				fprintf(stderr, "Word charset includes `%lc'.\n",
+				g_printerr("Word charset includes `%lc'.\n",
 					(wint_t) wbuf[i]);
 			}
 #endif
@@ -10739,7 +10738,7 @@ #endif
 			g_array_append_val(terminal->pvt->word_chars, range);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_MISC)) {
-				fprintf(stderr, "Word charset includes range from "
+				g_printerr("Word charset includes range from "
 					"`%lc' to `%lc'.\n", (wint_t) wbuf[i],
 					(wint_t) wbuf[i + 2]);
 			}
diff --git a/src/vteaccess.c b/src/vteaccess.c
index f9e7bca..38d8f96 100644
--- a/src/vteaccess.c
+++ b/src/vteaccess.c
@@ -165,7 +165,7 @@ emit_text_caret_moved(GObject *object, g
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Accessibility peer emitting "
+		g_printerr("Accessibility peer emitting "
 			"`text-caret-moved'.\n");
 	}
 #endif
@@ -196,10 +196,10 @@ emit_text_changed_insert(GObject *object
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Accessibility peer emitting "
+		g_printerr("Accessibility peer emitting "
 			"`text-changed::insert' (%ld, %ld) (%ld, %ld).\n",
 			offset, len, start, count);
-		fprintf(stderr, "Inserted text was `%.*s'.\n",
+		g_printerr("Inserted text was `%.*s'.\n",
 			(int) len, text + offset);
 	}
 #endif
@@ -230,10 +230,10 @@ emit_text_changed_delete(GObject *object
 	}
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Accessibility peer emitting "
+		g_printerr("Accessibility peer emitting "
 			"`text-changed::delete' (%ld, %ld) (%ld, %ld).\n",
 			offset, len, start, count);
-		fprintf(stderr, "Deleted text was `%.*s'.\n",
+		g_printerr("Deleted text was `%.*s'.\n",
 			(int) len, text + offset);
 	}
 #endif
@@ -378,7 +378,7 @@ vte_terminal_accessible_update_private_d
 			if ((i == 0) || (attrs.row != row)) {
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_MISC)) {
-					fprintf(stderr, "Row %d/%ld begins at "
+					g_printerr("Row %d/%ld begins at "
 						"%ld.\n",
 						priv->snapshot_linebreaks->len,
 						attrs.row, i);
@@ -398,7 +398,7 @@ #endif
 	vte_terminal_get_cursor_position(terminal, &ccol, &crow);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Cursor at (%ld, " "%ld).\n", ccol, crow);
+		g_printerr("Cursor at (%ld, " "%ld).\n", ccol, crow);
 	}
 #endif
 
@@ -436,7 +436,7 @@ #endif
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Refreshed accessibility snapshot, "
+		g_printerr("Refreshed accessibility snapshot, "
 			"%ld cells.\n", (long)priv->snapshot_attributes->len);
 	}
 #endif
@@ -677,7 +677,7 @@ vte_terminal_accessible_invalidate_curso
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Invalidating accessibility cursor.\n");
+		g_printerr("Invalidating accessibility cursor.\n");
 	}
 #endif
 	priv->snapshot_caret_invalid = TRUE;
@@ -862,7 +862,7 @@ vte_terminal_accessible_finalize(GObject
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Finalizing accessible peer.\n");
+		g_printerr("Finalizing accessible peer.\n");
 	}
 #endif
 
@@ -957,7 +957,7 @@ vte_terminal_accessible_get_text(AtkText
 				 VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Getting text from %d to %d of %d.\n",
+		g_printerr("Getting text from %d to %d of %d.\n",
 			start_offset, end_offset,
 			priv->snapshot_characters->len);
 	}
@@ -1011,7 +1011,7 @@ vte_terminal_accessible_get_text_somewhe
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Getting %s %s at %d of %d.\n",
+		g_printerr("Getting %s %s at %d of %d.\n",
 			(direction == direction_current) ? "this" :
 			((direction == direction_next) ? "next" : "previous"),
 			(boundary_type == ATK_TEXT_BOUNDARY_CHAR) ? "char" :
@@ -1128,7 +1128,7 @@ #endif
 			}
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_MISC)) {
-				fprintf(stderr, "Character %d is on line %d.\n",
+				g_printerr("Character %d is on line %d.\n",
 					offset, line);
 			}
 #endif
@@ -1146,7 +1146,7 @@ #endif
 						    int, line);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_MISC)) {
-				fprintf(stderr, "Line runs from %d to %d.\n",
+				g_printerr("Line runs from %d to %d.\n",
 					*start_offset, *end_offset);
 			}
 #endif
@@ -1569,7 +1569,7 @@ vte_terminal_accessible_text_init(gpoint
 	text = iface;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Initializing accessible peer's "
+		g_printerr("Initializing accessible peer's "
 			"AtkText interface.\n");
 	}
 #endif
@@ -1787,7 +1787,7 @@ vte_terminal_accessible_component_init(g
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Initializing accessible peer's "
+		g_printerr("Initializing accessible peer's "
 			"AtkComponent interface.\n");
 	}
 #endif
@@ -1936,7 +1936,7 @@ vte_terminal_accessible_factory_new(void
 	GObject *factory;
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Creating a new "
+		g_printerr("Creating a new "
 			"VteTerminalAccessibleFactory.\n");
 	}
 #endif
diff --git a/src/vteapp.c b/src/vteapp.c
index ec7a439..24e9db5 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -776,10 +776,10 @@ #endif
 					switch (i % 3) {
 					case 0:
 					case 1:
-						fprintf(stdout, "%ld\n", i);
+						g_print("%ld\n", i);
 						break;
 					case 2:
-						fprintf(stderr, "%ld\n", i);
+						g_printerr("%ld\n", i);
 						break;
 					}
 					sleep(1);
diff --git a/src/vtebg.c b/src/vtebg.c
index 9c8ffda..560b749 100644
--- a/src/vtebg.c
+++ b/src/vtebg.c
@@ -124,7 +124,7 @@ #ifdef VTE_DEBUG
 				gint pwidth, pheight;
 				gdk_drawable_get_size(pixmap,
 						      &pwidth, &pheight);
-				fprintf(stderr, "New background image %dx%d\n",
+				g_printerr("New background image %dx%d\n",
 					pwidth, pheight);
 			}
 #endif
@@ -417,7 +417,7 @@ _vte_bg_resize_pixbuf(GdkPixbuf *pixbuf,
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC) || _vte_debug_on(VTE_DEBUG_EVENTS)) {
-		fprintf(stderr, "Resizing (root?) pixbuf from %dx%d to %dx%d\n",
+		g_printerr("Resizing (root?) pixbuf from %dx%d to %dx%d\n",
 			src_width, src_height, dst_width, dst_height);
 	}
 #endif
diff --git a/src/vtedraw.c b/src/vtedraw.c
index ce4e9d5..dcc7c04 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -91,7 +91,7 @@ _vte_draw_new(GtkWidget *widget)
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "Using %s.\n", draw->impl->name);
+		g_printerr("Using %s.\n", draw->impl->name);
 	}
 #endif
 
diff --git a/src/vtepango.c b/src/vtepango.c
index a3d41bf..3a6676c 100644
--- a/src/vtepango.c
+++ b/src/vtepango.c
@@ -326,7 +326,7 @@ _vte_pango_set_text_font(struct _vte_dra
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "VtePango font metrics = %dx%d (%d).\n",
+		g_printerr("VtePango font metrics = %dx%d (%d).\n",
 			draw->width, draw->height, draw->ascent);
 	}
 #endif
diff --git a/src/vtepangox.c b/src/vtepangox.c
index b1464a5..4f43e2f 100644
--- a/src/vtepangox.c
+++ b/src/vtepangox.c
@@ -343,7 +343,7 @@ _vte_pango_x_set_text_font(struct _vte_d
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "VtePangoX font metrics = %dx%d (%d).\n",
+		g_printerr("VtePangoX font metrics = %dx%d (%d).\n",
 			draw->width, draw->height, draw->ascent);
 	}
 #endif
diff --git a/src/vteseq.c b/src/vteseq.c
index 5417063..15c850e 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -112,7 +112,7 @@ vte_terminal_emit_deiconify_window(VteTe
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `deiconify-window'.\n");
+		g_printerr("Emitting `deiconify-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "deiconify-window");
@@ -124,7 +124,7 @@ vte_terminal_emit_iconify_window(VteTerm
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `iconify-window'.\n");
+		g_printerr("Emitting `iconify-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "iconify-window");
@@ -136,7 +136,7 @@ vte_terminal_emit_icon_title_changed(Vte
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `icon-title-changed'.\n");
+		g_printerr("Emitting `icon-title-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "icon-title-changed");
@@ -148,7 +148,7 @@ vte_terminal_emit_window_title_changed(V
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `window-title-changed'.\n");
+		g_printerr("Emitting `window-title-changed'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "window-title-changed");
@@ -160,7 +160,7 @@ vte_terminal_emit_raise_window(VteTermin
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `raise-window'.\n");
+		g_printerr("Emitting `raise-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "raise-window");
@@ -172,7 +172,7 @@ vte_terminal_emit_lower_window(VteTermin
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `lower-window'.\n");
+		g_printerr("Emitting `lower-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "lower-window");
@@ -184,7 +184,7 @@ vte_terminal_emit_maximize_window(VteTer
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `maximize-window'.\n");
+		g_printerr("Emitting `maximize-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "maximize-window");
@@ -196,7 +196,7 @@ vte_terminal_emit_refresh_window(VteTerm
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `refresh-window'.\n");
+		g_printerr("Emitting `refresh-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "refresh-window");
@@ -208,7 +208,7 @@ vte_terminal_emit_restore_window(VteTerm
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `restore-window'.\n");
+		g_printerr("Emitting `restore-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "restore-window");
@@ -220,7 +220,7 @@ vte_terminal_emit_move_window(VteTermina
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `move-window'.\n");
+		g_printerr("Emitting `move-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "move-window", x, y);
@@ -233,7 +233,7 @@ vte_terminal_emit_resize_window(VteTermi
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
-		fprintf(stderr, "Emitting `resize-window'.\n");
+		g_printerr("Emitting `resize-window'.\n");
 	}
 #endif
 	g_signal_emit_by_name(terminal, "resize-window", width, height);
@@ -423,7 +423,7 @@ vte_sequence_handler_set_title_internal(
 					      &outbuf, &outbuf_len) == -1) {
 #ifdef VTE_DEBUG
 					if (_vte_debug_on(VTE_DEBUG_IO)) {
-						fprintf(stderr, "Error "
+						g_printerr("Error "
 							"converting %ld title "
 							"bytes (%s), "
 							"skipping.\n",
@@ -663,7 +663,7 @@ vte_sequence_handler_decset_internal(Vte
 			set = (p != NULL);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Setting %d was %s.\n",
+				g_printerr("Setting %d was %s.\n",
 					setting, set ? "set" : "unset");
 			}
 #endif
@@ -683,7 +683,7 @@ #endif
 			}
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Setting %d is %s, saving.\n",
+				g_printerr("Setting %d is %s, saving.\n",
 					setting, set ? "set" : "unset");
 			}
 #endif
@@ -695,7 +695,7 @@ #endif
 		if (!save) {
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Setting %d to %s.\n",
+				g_printerr("Setting %d to %s.\n",
 					setting, set ? "set" : "unset");
 			}
 #endif
@@ -727,9 +727,9 @@ #endif
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 			if (set) {
-				fprintf(stderr, "Entering application cursor mode.\n");
+				g_printerr("Entering application cursor mode.\n");
 			} else {
-				fprintf(stderr, "Leaving application cursor mode.\n");
+				g_printerr("Leaving application cursor mode.\n");
 			}
 		}
 #endif
@@ -830,9 +830,9 @@ #endif
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 			if (set) {
-				fprintf(stderr, "Entering application keypad mode.\n");
+				g_printerr("Entering application keypad mode.\n");
 			} else {
-				fprintf(stderr, "Leaving application keypad mode.\n");
+				g_printerr("Leaving application keypad mode.\n");
 			}
 		}
 #endif
@@ -841,9 +841,9 @@ #endif
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 			if (set) {
-				fprintf(stderr, "Entering Sun fkey mode.\n");
+				g_printerr("Entering Sun fkey mode.\n");
 			} else {
-				fprintf(stderr, "Leaving Sun fkey mode.\n");
+				g_printerr("Leaving Sun fkey mode.\n");
 			}
 		}
 #endif
@@ -852,9 +852,9 @@ #endif
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 			if (set) {
-				fprintf(stderr, "Entering HP fkey mode.\n");
+				g_printerr("Entering HP fkey mode.\n");
 			} else {
-				fprintf(stderr, "Leaving HP fkey mode.\n");
+				g_printerr("Leaving HP fkey mode.\n");
 			}
 		}
 #endif
@@ -863,9 +863,9 @@ #endif
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 			if (set) {
-				fprintf(stderr, "Entering Legacy fkey mode.\n");
+				g_printerr("Entering Legacy fkey mode.\n");
 			} else {
-				fprintf(stderr, "Leaving Legacy fkey mode.\n");
+				g_printerr("Leaving Legacy fkey mode.\n");
 			}
 		}
 #endif
@@ -874,9 +874,9 @@ #endif
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
 			if (set) {
-				fprintf(stderr, "Entering VT220 fkey mode.\n");
+				g_printerr("Entering VT220 fkey mode.\n");
 			} else {
-				fprintf(stderr, "Leaving VT220 fkey mode.\n");
+				g_printerr("Leaving VT220 fkey mode.\n");
 			}
 		}
 #endif
@@ -1088,7 +1088,7 @@ vte_sequence_handler_bt(VteTerminal *ter
 	/* Warp the cursor. */
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-		fprintf(stderr, "Moving cursor to column %ld.\n", (long)newcol);
+		g_printerr("Moving cursor to column %ld.\n", (long)newcol);
 	}
 #endif
 	terminal->pvt->screen->cursor_current.col = newcol;
@@ -3143,7 +3143,7 @@ vte_sequence_handler_application_keypad(
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
-		fprintf(stderr, "Entering application keypad mode.\n");
+		g_printerr("Entering application keypad mode.\n");
 	}
 #endif
 	terminal->pvt->keypad_mode = VTE_KEYMODE_APPLICATION;
@@ -3158,7 +3158,7 @@ vte_sequence_handler_normal_keypad(VteTe
 {
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
-		fprintf(stderr, "Leaving application keypad mode.\n");
+		g_printerr("Leaving application keypad mode.\n");
 	}
 #endif
 	terminal->pvt->keypad_mode = VTE_KEYMODE_NORMAL;
@@ -3799,7 +3799,7 @@ vte_sequence_handler_window_manipulation
 		case 1:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Deiconifying window.\n");
+				g_printerr("Deiconifying window.\n");
 			}
 #endif
 			vte_terminal_emit_deiconify_window(terminal);
@@ -3807,7 +3807,7 @@ #endif
 		case 2:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Iconifying window.\n");
+				g_printerr("Iconifying window.\n");
 			}
 #endif
 			vte_terminal_emit_iconify_window(terminal);
@@ -3816,7 +3816,7 @@ #endif
 			if ((arg1 != -1) && (arg2 != -2)) {
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-					fprintf(stderr, "Moving window to "
+					g_printerr("Moving window to "
 						"%ld,%ld.\n", arg1, arg2);
 				}
 #endif
@@ -3829,7 +3829,7 @@ #endif
 			if ((arg1 != -1) && (arg2 != -1)) {
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-					fprintf(stderr, "Resizing window "
+					g_printerr("Resizing window "
 						"(to %ldx%ld pixels).\n",
 						arg2, arg1);
 				}
@@ -3845,7 +3845,7 @@ #endif
 		case 5:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Raising window.\n");
+				g_printerr("Raising window.\n");
 			}
 #endif
 			vte_terminal_emit_raise_window(terminal);
@@ -3853,7 +3853,7 @@ #endif
 		case 6:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Lowering window.\n");
+				g_printerr("Lowering window.\n");
 			}
 #endif
 			vte_terminal_emit_lower_window(terminal);
@@ -3861,7 +3861,7 @@ #endif
 		case 7:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Refreshing window.\n");
+				g_printerr("Refreshing window.\n");
 			}
 #endif
 			_vte_invalidate_all(terminal);
@@ -3871,7 +3871,7 @@ #endif
 			if ((arg1 != -1) && (arg2 != -1)) {
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-					fprintf(stderr, "Resizing window "
+					g_printerr("Resizing window "
 						"(to %ld columns, %ld rows).\n",
 						arg2, arg1);
 				}
@@ -3889,7 +3889,7 @@ #endif
 			case 0:
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-					fprintf(stderr, "Restoring window.\n");
+					g_printerr("Restoring window.\n");
 				}
 #endif
 				vte_terminal_emit_restore_window(terminal);
@@ -3897,7 +3897,7 @@ #endif
 			case 1:
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-					fprintf(stderr, "Maximizing window.\n");
+					g_printerr("Maximizing window.\n");
 				}
 #endif
 				vte_terminal_emit_maximize_window(terminal);
@@ -3914,7 +3914,7 @@ #endif
 				 1 + !GTK_WIDGET_MAPPED(widget));
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Reporting window state %s.\n",
+				g_printerr("Reporting window state %s.\n",
 					GTK_WIDGET_MAPPED(widget) ?
 					"non-iconified" : "iconified");
 			}
@@ -3930,7 +3930,7 @@ #endif
 				 width + VTE_PAD_WIDTH, height + VTE_PAD_WIDTH);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Reporting window location"
+				g_printerr("Reporting window location"
 					"(%d++,%d++).\n",
 					width, height);
 			}
@@ -3947,7 +3947,7 @@ #endif
 				 width - 2 * VTE_PAD_WIDTH);
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Reporting window size "
+				g_printerr("Reporting window size "
 					"(%dx%dn",
 					width - 2 * VTE_PAD_WIDTH,
 					height - 2 * VTE_PAD_WIDTH);
@@ -3959,7 +3959,7 @@ #endif
 			/* Send widget size, in cells. */
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Reporting widget size.\n");
+				g_printerr("Reporting widget size.\n");
 			}
 #endif
 			snprintf(buf, sizeof(buf),
@@ -3971,7 +3971,7 @@ #endif
 		case 19:
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Reporting screen size.\n");
+				g_printerr("Reporting screen size.\n");
 			}
 #endif
 			if (gtk_widget_has_screen(widget)) {
@@ -3991,7 +3991,7 @@ #endif
 			/* Report the icon title. */
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Reporting icon title.\n");
+				g_printerr("Reporting icon title.\n");
 			}
 #endif
 			snprintf(buf, sizeof(buf),
@@ -4005,7 +4005,7 @@ #endif
 			/* Report the window title. */
 #ifdef VTE_DEBUG
 			if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-				fprintf(stderr, "Reporting window title.\n");
+				g_printerr("Reporting window title.\n");
 			}
 #endif
 			snprintf(buf, sizeof(buf),
@@ -4019,7 +4019,7 @@ #endif
 			if (param >= 24) {
 #ifdef VTE_DEBUG
 				if (_vte_debug_on(VTE_DEBUG_PARSE)) {
-					fprintf(stderr, "Resizing to %ld rows.\n",
+					g_printerr("Resizing to %ld rows.\n",
 						param);
 				}
 #endif
diff --git a/src/vtetc.c b/src/vtetc.c
index 1212898..e56abc0 100644
--- a/src/vtetc.c
+++ b/src/vtetc.c
@@ -549,7 +549,7 @@ main (int argc, char **argv)
 
   if (argc < 4)
   {
-    fprintf (stderr, "vtetc /path/to/termcap termname attrs...\n"
+    g_printerr("vtetc /path/to/termcap termname attrs...\n"
                      "  where attrs are\n"
                      "    :xx for boolean\n"
                      "    =xx for string\n"
@@ -599,7 +599,7 @@ main (int argc, char **argv)
         break;
 
       default:
-        fprintf (stderr, "unrecognised type '%c'\n", argv[i][0]);
+        g_printerr("unrecognised type '%c'\n", argv[i][0]);
     }
   }
 
diff --git a/src/vtexft.c b/src/vtexft.c
index 1e5cd87..d02055b 100644
--- a/src/vtexft.c
+++ b/src/vtexft.c
@@ -572,7 +572,7 @@ _vte_xft_set_text_font(struct _vte_draw 
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
-		fprintf(stderr, "VteXft font metrics = %dx%d (%d).\n",
+		g_printerr("VteXft font metrics = %dx%d (%d).\n",
 			draw->width, draw->height, draw->ascent);
 	}
 #endif
