diff --git a/src/vte-private.h b/src/vte-private.h
index d1540e9..81afda4 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -365,7 +365,7 @@ void _vte_invalidate_all(VteTerminal *te
 void _vte_invalidate_cells(VteTerminal *terminal,
 			   glong column_start, gint column_count,
 			   glong row_start, gint row_count);
-void _vte_invalidate_cursor_once(gpointer data, gboolean periodic);
+void _vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic);
 VteRowData * _vte_new_row_data(VteTerminal *terminal);
 VteRowData * _vte_new_row_data_sized(VteTerminal *terminal, gboolean fill);
 void _vte_terminal_adjust_adjustments(VteTerminal *terminal, gboolean immediate);
diff --git a/src/vte.c b/src/vte.c
index 329d7cc..bf712bb 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -58,12 +58,12 @@ static void vte_terminal_set_termcap(Vte
 static void vte_terminal_paste(VteTerminal *terminal, GdkAtom board);
 static gboolean vte_terminal_io_read(GIOChannel *channel,
 				     GIOCondition condition,
-				     gpointer data);
+				     VteTerminal *terminal);
 static gboolean vte_terminal_io_write(GIOChannel *channel,
 				      GIOCondition condition,
-				      gpointer data);
+				      VteTerminal *terminal);
 static void vte_terminal_match_hilite_clear(VteTerminal *terminal);
-static gboolean vte_terminal_background_update(gpointer data);
+static gboolean vte_terminal_background_update(VteTerminal *data);
 static void vte_terminal_queue_background_update(VteTerminal *terminal);
 static void vte_terminal_queue_adjustment_changed(VteTerminal *terminal);
 static gboolean vte_terminal_process_incoming(VteTerminal *terminal);
@@ -110,7 +110,7 @@ static void
 vte_free_row_data(gpointer freeing, gpointer data)
 {
 	if (freeing) {
-		VteRowData *row = (VteRowData*) freeing;
+		VteRowData *row = freeing;
 		g_array_free(row->cells, TRUE);
 		g_slice_free(VteRowData, row);
 	}
@@ -121,11 +121,9 @@ vte_free_row_data(gpointer freeing, gpoi
 static void
 vte_g_array_fill(GArray *array, gpointer item, guint final_size)
 {
-	g_assert(array != NULL);
 	if (array->len >= final_size) {
 		return;
 	}
-	g_assert(item != NULL);
 
 	while (array->len < final_size) {
 		g_array_append_vals(array, item, 1);
@@ -360,7 +358,6 @@ vte_terminal_find_charcell(VteTerminal *
 	VteRowData *rowdata;
 	struct vte_charcell *ret = NULL;
 	VteScreen *screen;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	screen = terminal->pvt->screen;
 	if (_vte_ring_contains(screen->row_data, row)) {
 		rowdata = _vte_ring_index(screen->row_data, VteRowData *, row);
@@ -383,8 +380,6 @@ vte_terminal_preedit_width(VteTerminal *
 	gssize ret = 0;
 	const char *preedit = NULL;
 
-	g_assert(VTE_IS_TERMINAL(terminal));
-
 	if (terminal->pvt->im_preedit != NULL) {
 		preedit = terminal->pvt->im_preedit;
 		for (i = 0;
@@ -409,8 +404,6 @@ vte_terminal_preedit_length(VteTerminal 
 	int i = 0;
 	const char *preedit = NULL;
 
-	g_assert(VTE_IS_TERMINAL(terminal));
-
 	if (terminal->pvt->im_preedit != NULL) {
 		preedit = terminal->pvt->im_preedit;
 		for (i = 0;
@@ -427,20 +420,13 @@ vte_terminal_preedit_length(VteTerminal 
 
 /* Cause the cursor to be redrawn. */
 void
-_vte_invalidate_cursor_once(gpointer data, gboolean periodic)
+_vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic)
 {
-	VteTerminal *terminal;
 	VteScreen *screen;
 	struct vte_charcell *cell;
 	gssize preedit_width;
 	int column, columns, row;
 
-	if (!VTE_IS_TERMINAL(data)) {
-		return;
-	}
-
-	terminal = VTE_TERMINAL(data);
-
 	if (terminal->pvt->visibility_state == GDK_VISIBILITY_FULLY_OBSCURED) {
 		return;
 	}
@@ -452,7 +438,7 @@ _vte_invalidate_cursor_once(gpointer dat
 	}
 
 	if (terminal->pvt->cursor_visible &&
-	    GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
+	    GTK_WIDGET_DRAWABLE(terminal)) {
 		preedit_width = vte_terminal_preedit_width(terminal, FALSE);
 
 		screen = terminal->pvt->screen;
@@ -498,27 +484,22 @@ #endif
 
 /* Invalidate the cursor repeatedly. */
 static gboolean
-vte_invalidate_cursor_periodic (gpointer data)
+vte_invalidate_cursor_periodic (VteTerminal *terminal)
 {
-	VteTerminal *terminal;
 	GtkSettings *settings;
 	int blink_cycle = 1000;
 	int timeout = INT_MAX;
 	static gboolean have_timeout;
 	static gboolean have_queried_timeout;
 
-	g_assert(VTE_IS_TERMINAL(data));
-
-	terminal = VTE_TERMINAL (data);
-
-	settings = gtk_widget_get_settings (GTK_WIDGET (data));
+	settings = gtk_widget_get_settings (&terminal->widget);
 
 	terminal->pvt->cursor_blink_state = !terminal->pvt->cursor_blink_state;
 	terminal->pvt->cursor_blink_time += terminal->pvt->cursor_blink_timeout;
 
 	_vte_invalidate_cursor_once(terminal, TRUE);
 
-	if (!GTK_IS_SETTINGS (settings))
+	if (settings == NULL)
 		return TRUE;
 
 	/* Temporary hack to prevent GObject complaining about missing
@@ -560,7 +541,7 @@ vte_invalidate_cursor_periodic (gpointer
 	terminal->pvt->cursor_blink_timeout = blink_cycle;
 	terminal->pvt->cursor_blink_tag = g_timeout_add_full(G_PRIORITY_LOW,
 							     terminal->pvt->cursor_blink_timeout,
-							     vte_invalidate_cursor_periodic,
+							     (GSourceFunc)vte_invalidate_cursor_periodic,
 							     terminal,
 							     NULL);
 	return FALSE;
@@ -788,7 +769,6 @@ #endif
 static void
 vte_terminal_deselect_all(VteTerminal *terminal)
 {
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if (terminal->pvt->has_selection) {
 		terminal->pvt->has_selection = FALSE;
 #ifdef VTE_DEBUG
@@ -846,7 +826,6 @@ static void
 vte_terminal_set_default_tabstops(VteTerminal *terminal)
 {
 	int i, width;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if (terminal->pvt->tabstops != NULL) {
 		g_hash_table_destroy(terminal->pvt->tabstops);
 	}
@@ -889,7 +868,6 @@ static void
 vte_terminal_match_contents_refresh(VteTerminal *terminal)
 {
 	GArray *array;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	_vte_terminal_match_contents_clear(terminal);
 	array = g_array_new(FALSE, TRUE, sizeof(struct _VteCharAttributes));
 	terminal->pvt->match_contents = vte_terminal_get_text(terminal,
@@ -974,9 +952,7 @@ vte_terminal_cursor_new(VteTerminal *ter
 	GdkDisplay *display;
 	GdkCursor *cursor;
 
-	g_assert(VTE_IS_TERMINAL(terminal));
-
-	display = gtk_widget_get_display(GTK_WIDGET(terminal));
+	display = gtk_widget_get_display(&terminal->widget);
 	cursor = gdk_cursor_new_for_display(display, cursor_type);
 	return cursor;
 }
@@ -1113,7 +1089,6 @@ #endif
 	if (end != NULL) {
 		*end = 0;
 	}
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if (terminal->pvt->match_contents == NULL) {
 		vte_terminal_match_contents_refresh(terminal);
 	}
@@ -1230,8 +1205,8 @@ #endif
 						*end = coffset +
 						       matches[j].rm_eo - 1;
 					}
-					if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
-						gdk_window_set_cursor((GTK_WIDGET(terminal))->window,
+					if (GTK_WIDGET_REALIZED(terminal)) {
+						gdk_window_set_cursor(terminal->widget.window,
 								      regex->cursor);
 					}
 					terminal->pvt->match_previous = regex->tag;
@@ -1299,10 +1274,8 @@ #endif
 
 /* Emit an adjustment changed signal on our adjustment object. */
 static gboolean
-vte_terminal_emit_adjustment_changed(gpointer data)
+vte_terminal_emit_adjustment_changed(VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-	terminal = VTE_TERMINAL(data);
 	if (terminal->pvt->adjustment_changed_tag) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SIGNALS)) {
@@ -1322,7 +1295,7 @@ vte_terminal_queue_adjustment_changed(Vt
 	if (terminal->pvt->adjustment_changed_tag == 0) {
 		terminal->pvt->adjustment_changed_tag =
 				g_idle_add_full(VTE_ADJUSTMENT_PRIORITY,
-						vte_terminal_emit_adjustment_changed,
+						(GSourceFunc)vte_terminal_emit_adjustment_changed,
 						terminal,
 						NULL);
 	} else {
@@ -1493,7 +1466,6 @@ static void
 vte_terminal_scroll_pages(VteTerminal *terminal, gint pages)
 {
 	glong destination;
-	g_assert(VTE_IS_TERMINAL(terminal));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_IO)) {
 		g_printerr("Scrolling %d pages.\n", pages);
@@ -1519,7 +1491,6 @@ static void
 vte_terminal_maybe_scroll_to_top(VteTerminal *terminal)
 {
 	long delta;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if (floor(gtk_adjustment_get_value(terminal->adjustment)) !=
 	    _vte_ring_delta(terminal->pvt->screen->row_data)) {
 		delta = _vte_ring_delta(terminal->pvt->screen->row_data);
@@ -1531,7 +1502,6 @@ static void
 vte_terminal_maybe_scroll_to_bottom(VteTerminal *terminal)
 {
 	glong delta;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if ((terminal->pvt->screen->scroll_delta !=
 	    terminal->pvt->screen->insert_delta)) {
 		delta = terminal->pvt->screen->insert_delta;
@@ -1782,9 +1752,8 @@ #endif
 		cursor = terminal->pvt->mouse_inviso_cursor;
 	}
 	if (cursor) {
-		if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
-			gdk_window_set_cursor((GTK_WIDGET(terminal))->window,
-					      cursor);
+		if (GTK_WIDGET_REALIZED(terminal)) {
+			gdk_window_set_cursor(terminal->widget.window, cursor);
 		}
 	}
 	terminal->pvt->mouse_cursor_visible = visible;
@@ -1806,7 +1775,7 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	return GTK_WIDGET(g_object_new(vte_terminal_get_type(), NULL));
+	return g_object_new(vte_terminal_get_type(), NULL);
 }
 
 /* Set up a palette entry with a more-or-less match for the requested color. */
@@ -1814,20 +1783,13 @@ static void
 vte_terminal_set_color_internal(VteTerminal *terminal, int entry,
 				const GdkColor *proposed)
 {
-	GtkWidget *widget;
-
-	g_assert(VTE_IS_TERMINAL(terminal));
-	g_assert(entry >= 0);
-	g_assert(entry < G_N_ELEMENTS(terminal->pvt->palette));
-
 	/* Save the requested color. */
 	terminal->pvt->palette[entry].red = proposed->red;
 	terminal->pvt->palette[entry].green = proposed->green;
 	terminal->pvt->palette[entry].blue = proposed->blue;
 
 	/* If we're not realized yet, there's nothing else to do. */
-	widget = GTK_WIDGET(terminal);
-	if (!GTK_WIDGET_REALIZED(widget)) {
+	if (!GTK_WIDGET_REALIZED(terminal)) {
 		return;
 	}
 
@@ -1901,6 +1863,9 @@ #endif
 void
 vte_terminal_set_color_bold(VteTerminal *terminal, const GdkColor *bold)
 {
+	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+	g_return_if_fail(bold != NULL);
+
 	vte_terminal_set_color_internal(terminal, VTE_BOLD_FG, bold);
 }
 
@@ -1915,6 +1880,9 @@ vte_terminal_set_color_bold(VteTerminal 
 void
 vte_terminal_set_color_dim(VteTerminal *terminal, const GdkColor *dim)
 {
+	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+	g_return_if_fail(dim != NULL);
+
 	vte_terminal_set_color_internal(terminal, VTE_DIM_FG, dim);
 }
 
@@ -1930,6 +1898,9 @@ void
 vte_terminal_set_color_foreground(VteTerminal *terminal,
 				  const GdkColor *foreground)
 {
+	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+	g_return_if_fail(foreground != NULL);
+
 	vte_terminal_set_color_internal(terminal, VTE_DEF_FG, foreground);
 }
 
@@ -1947,6 +1918,9 @@ void
 vte_terminal_set_color_background(VteTerminal *terminal,
 				  const GdkColor *background)
 {
+	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+	g_return_if_fail(background != NULL);
+
 	vte_terminal_set_color_internal(terminal, VTE_DEF_BG, background);
 }
 
@@ -1966,6 +1940,8 @@ void
 vte_terminal_set_color_cursor(VteTerminal *terminal,
 			      const GdkColor *cursor_background)
 {
+	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
 	if (cursor_background != NULL) {
 		vte_terminal_set_color_internal(terminal, VTE_CUR_BG,
 						cursor_background);
@@ -1991,6 +1967,8 @@ void
 vte_terminal_set_color_highlight(VteTerminal *terminal,
 				 const GdkColor *highlight_background)
 {
+	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
 	if (highlight_background != NULL) {
 		vte_terminal_set_color_internal(terminal, VTE_DEF_HL,
 						highlight_background);
@@ -2430,38 +2408,23 @@ #endif
 
 /* Handle a terminal control sequence and its parameters. */
 static gboolean
-vte_terminal_handle_sequence(GtkWidget *widget,
+vte_terminal_handle_sequence(VteTerminal *terminal,
 			     const char *match_s,
 			     GQuark match,
 			     GValueArray *params)
 {
-	VteTerminal *terminal;
 	VteTerminalSequenceHandler handler;
-	VteScreen *screen;
-	struct vte_cursor_position position;
 	gboolean ret;
 
-	g_assert(widget != NULL);
-	g_assert(VTE_IS_TERMINAL(widget));
-	terminal = VTE_TERMINAL(widget);
-	screen = terminal->pvt->screen;
-
-	/* This may generate multiple redraws, so freeze it while we do them. */
-	if (GTK_WIDGET_REALIZED (widget)) {
-		gdk_window_freeze_updates(widget->window);
-	}
-
-	/* Save the cursor's current position for future use. */
-	position = screen->cursor_current;
-
-	/* Find the handler for this control sequence. */
-	handler = _vte_sequence_get_handler (match_s, match);
-
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_PARSE)) {
 		display_control_sequence(match_s, params);
 	}
 #endif
+
+	/* Find the handler for this control sequence. */
+	handler = _vte_sequence_get_handler (match_s, match);
+
 	if (handler != NULL) {
 		/* Let the handler handle it. */
 		ret = handler(terminal, match_s, match, params);
@@ -2471,21 +2434,16 @@ #ifdef VTE_DEBUG
 				match_s);
 #else
 		/* suppress multiple warnings for each widget */
-		if (!g_object_get_qdata(G_OBJECT (widget), match)) {
+		if (!g_object_get_qdata(G_OBJECT (terminal), match)) {
 			g_warning(_("No handler for control sequence `%s' defined."),
 					match_s);
-			g_object_set_qdata(G_OBJECT (widget),
+			g_object_set_qdata(G_OBJECT (terminal),
 					match, (gpointer)0x1);
 		}
 #endif
 		ret = FALSE;
 	}
 
-	/* Let the updating begin. */
-	if (GTK_WIDGET_REALIZED (widget)) {
-		gdk_window_thaw_updates(widget->window);
-	}
-
 	return ret;
 }
 
@@ -2493,20 +2451,17 @@ #endif
  * looking for, emit one of our own. */
 static void
 vte_terminal_catch_child_exited(VteReaper *reaper, int pid, int status,
-				VteTerminal *data)
+				VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
 	if (pid == terminal->pvt->pty_pid) {
 		/* Disconnect from the reaper. */
-		if (VTE_IS_REAPER(terminal->pvt->pty_reaper)) {
+		if (terminal->pvt->pty_reaper != NULL) {
 			g_signal_handlers_disconnect_by_func(terminal->pvt->pty_reaper,
-							     (gpointer)vte_terminal_catch_child_exited,
+							     vte_terminal_catch_child_exited,
 							     terminal);
-			g_object_unref(G_OBJECT(terminal->pvt->pty_reaper));
+			g_object_unref(terminal->pvt->pty_reaper);
+			terminal->pvt->pty_reaper = NULL;
 		}
-		terminal->pvt->pty_reaper = NULL;
 		terminal->pvt->pty_pid = -1;
 
 		/* Close out the PTY. */
@@ -2551,7 +2506,7 @@ _vte_terminal_connect_pty_read(VteTermin
 			g_io_add_watch_full(terminal->pvt->pty_input,
 					    VTE_CHILD_INPUT_PRIORITY,
 					    G_IO_IN | G_IO_HUP,
-					    vte_terminal_io_read,
+					    (GIOFunc)vte_terminal_io_read,
 					    terminal,
 					    NULL);
 	}
@@ -2573,7 +2528,7 @@ _vte_terminal_connect_pty_write(VteTermi
 			g_io_add_watch_full(terminal->pvt->pty_output,
 					    VTE_CHILD_OUTPUT_PRIORITY,
 					    G_IO_OUT,
-					    vte_terminal_io_write,
+					    (GIOFunc)vte_terminal_io_write,
 					    terminal,
 					    NULL);
 	}
@@ -2624,11 +2579,8 @@ _vte_terminal_fork_basic(VteTerminal *te
 	char **env_add;
 	int i;
 	pid_t pid;
-	GtkWidget *widget;
 	VteReaper *reaper;
 
-	widget = GTK_WIDGET(terminal);
-
 	/* Duplicate the environment, and add one more variable. */
 	for (i = 0; (envv != NULL) && (envv[i] != NULL); i++) {
 		/* nothing */ ;
@@ -2671,28 +2623,30 @@ _vte_terminal_fork_basic(VteTerminal *te
 		/* Catch a child-exited signal from the child pid. */
 		reaper = vte_reaper_get();
 		vte_reaper_add_child((GPid) pid);
-		g_object_ref(G_OBJECT(reaper));
-		if (VTE_IS_REAPER(terminal->pvt->pty_reaper)) {
+		g_object_ref(reaper);
+		if (terminal->pvt->pty_reaper != NULL) {
 			g_signal_handlers_disconnect_by_func(terminal->pvt->pty_reaper,
-							     (gpointer)vte_terminal_catch_child_exited,
+							     vte_terminal_catch_child_exited,
 							     terminal);
-			g_object_unref(G_OBJECT(terminal->pvt->pty_reaper));
+			g_object_unref(terminal->pvt->pty_reaper);
 		}
-		g_signal_connect(G_OBJECT(reaper), "child-exited",
+		g_signal_connect(reaper, "child-exited",
 				 G_CALLBACK(vte_terminal_catch_child_exited),
 				 terminal);
 		terminal->pvt->pty_reaper = reaper;
 
 		/* Set the pty to be non-blocking. */
 		i = fcntl(terminal->pvt->pty_master, F_GETFL);
-		fcntl(terminal->pvt->pty_master, F_SETFL, i | O_NONBLOCK);
+		if ((i & O_NONBLOCK) == 0) {
+			fcntl(terminal->pvt->pty_master, F_SETFL, i | O_NONBLOCK);
+		}
 
 		/* Set the PTY size. */
 		vte_terminal_set_size(terminal,
 				      terminal->column_count,
 				      terminal->row_count);
-		if (GTK_WIDGET_REALIZED(widget)) {
-			gtk_widget_queue_resize(widget);
+		if (GTK_WIDGET_REALIZED(terminal)) {
+			gtk_widget_queue_resize(&terminal->widget);
 		}
 
 		/* Open a channel to listen for input on. */
@@ -2819,13 +2773,8 @@ vte_terminal_forkpty(VteTerminal *termin
 
 /* Handle an EOF from the client. */
 static void
-vte_terminal_eof(GIOChannel *channel, gpointer data)
+vte_terminal_eof(GIOChannel *channel, VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
-
 	/* Close the connections to the child -- note that the source channel
 	 * has already been dereferenced. */
 	if (channel == terminal->pvt->pty_input) {
@@ -2861,8 +2810,7 @@ vte_terminal_eof(GIOChannel *channel, gp
 static void
 vte_terminal_im_reset(VteTerminal *terminal)
 {
-	g_assert(VTE_IS_TERMINAL(terminal));
-	if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
+	if (GTK_WIDGET_REALIZED(terminal)) {
 		gtk_im_context_reset(terminal->pvt->im_context);
 		if (terminal->pvt->im_preedit != NULL) {
 			g_free(terminal->pvt->im_preedit);
@@ -2946,7 +2894,6 @@ vte_terminal_process_incoming(VteTermina
 	GValueArray *params = NULL;
 	VteScreen *screen;
 	struct vte_cursor_position cursor;
-	GtkWidget *widget;
 	GdkRectangle rect;
 	GdkPoint bbox_topleft, bbox_bottomright;
 	gunichar *wbuf, c;
@@ -2958,10 +2905,6 @@ vte_terminal_process_incoming(VteTermina
 	gboolean invalidated_text;
 	GArray *unichars;
 
-	g_assert(GTK_IS_WIDGET(terminal));
-	g_assert(VTE_IS_TERMINAL(terminal));
-	widget = GTK_WIDGET(terminal);
-
 	bottom = (terminal->pvt->screen->insert_delta ==
 		  terminal->pvt->screen->scroll_delta);
 
@@ -3033,7 +2976,7 @@ #endif
 			}
 			/* Call the right sequence handler for the requested
 			 * behavior. */
-			again = vte_terminal_handle_sequence(GTK_WIDGET(terminal),
+			again = vte_terminal_handle_sequence(terminal,
 							     match,
 							     quark,
 							     params);
@@ -3276,7 +3219,7 @@ #endif
 	}
 
 	/* Tell the input method where the cursor is. */
-	if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
+	if (GTK_WIDGET_REALIZED(terminal)) {
 		rect.x = terminal->pvt->screen->cursor_current.col *
 			 terminal->char_width + VTE_PAD_WIDTH;
 		rect.width = terminal->char_width;
@@ -3302,18 +3245,12 @@ #endif
 static gboolean
 vte_terminal_io_read(GIOChannel *channel,
 		     GIOCondition condition,
-		     gpointer data)
+		     VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-	GtkWidget *widget;
 	char buf[VTE_INPUT_CHUNK_SIZE];
 	int bcount, fd;
 	gboolean eof, leave_open = TRUE;
 
-	g_assert(VTE_IS_TERMINAL(data));
-	widget = GTK_WIDGET(data);
-	terminal = VTE_TERMINAL(data);
-
 	/* Check that the channel is still open. */
 	fd = g_io_channel_unix_get_fd(channel);
 
@@ -3411,16 +3348,12 @@ vte_terminal_feed(VteTerminal *terminal,
 static gboolean
 vte_terminal_io_write(GIOChannel *channel,
 		      GIOCondition condition,
-		      gpointer data)
+		      VteTerminal *terminal)
 {
-	VteTerminal *terminal;
 	gssize count;
 	int fd;
 	gboolean leave_open;
 
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
-
 	fd = g_io_channel_unix_get_fd(channel);
 
 	count = write(fd, terminal->pvt->outgoing->bytes,
@@ -3460,7 +3393,7 @@ vte_terminal_send(VteTerminal *terminal,
 {
 	gssize icount, ocount;
 	char *ibuf, *obuf, *obufptr, *cooked;
-	VteConv *conv;
+	VteConv conv;
 	long crcount, cooked_length, i;
 
 	g_assert(VTE_IS_TERMINAL(terminal));
@@ -3468,10 +3401,10 @@ vte_terminal_send(VteTerminal *terminal,
 
 	conv = NULL;
 	if (strcmp(encoding, "UTF-8") == 0) {
-		conv = &terminal->pvt->outgoing_conv;
+		conv = terminal->pvt->outgoing_conv;
 	}
 	g_assert(conv != NULL);
-	g_assert(*conv != ((VteConv) -1));
+	g_assert(conv != ((VteConv) -1));
 
 	icount = length;
 	ibuf = (char *) data;
@@ -3479,7 +3412,7 @@ vte_terminal_send(VteTerminal *terminal,
 	_vte_buffer_set_minimum_size(terminal->pvt->conv_buffer, ocount);
 	obuf = obufptr = terminal->pvt->conv_buffer->bytes;
 
-	if (_vte_conv(*conv, &ibuf, &icount, &obuf, &ocount) == -1) {
+	if (_vte_conv(conv, &ibuf, &icount, &obuf, &ocount) == -1) {
 		g_warning(_("Error (%s) converting data for child, dropping."),
 			  strerror(errno));
 	} else {
@@ -3643,18 +3576,13 @@ vte_terminal_feed_child_using_modes(VteT
 
 /* Send text from the input method to the child. */
 static void
-vte_terminal_im_commit(GtkIMContext *im_context, gchar *text, gpointer data)
+vte_terminal_im_commit(GtkIMContext *im_context, gchar *text, VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-
-	g_assert(VTE_IS_TERMINAL(data));
-	g_assert(GTK_IS_IM_CONTEXT(im_context));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		g_printerr("Input method committed `%s'.\n", text);
 	}
 #endif
-	terminal = VTE_TERMINAL(data);
 	vte_terminal_feed_child_using_modes(terminal, text, -1);
 	/* Committed text was committed because the user pressed a key, so
 	 * we need to obey the scroll-on-keystroke setting. */
@@ -3665,14 +3593,8 @@ #endif
 
 /* We've started pre-editing. */
 static void
-vte_terminal_im_preedit_start(GtkIMContext *im_context, gpointer data)
+vte_terminal_im_preedit_start(GtkIMContext *im_context, VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
-	g_assert(GTK_IS_IM_CONTEXT(im_context));
-
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		g_printerr("Input method pre-edit started.\n");
@@ -3683,14 +3605,8 @@ #endif
 
 /* We've stopped pre-editing. */
 static void
-vte_terminal_im_preedit_end(GtkIMContext *im_context, gpointer data)
+vte_terminal_im_preedit_end(GtkIMContext *im_context, VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
-	g_assert(GTK_IS_IM_CONTEXT(im_context));
-
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		g_printerr("Input method pre-edit ended.\n");
@@ -3701,17 +3617,12 @@ #endif
 
 /* The pre-edit string changed. */
 static void
-vte_terminal_im_preedit_changed(GtkIMContext *im_context, gpointer data)
+vte_terminal_im_preedit_changed(GtkIMContext *im_context, VteTerminal *terminal)
 {
 	gchar *str;
 	PangoAttrList *attrs;
-	VteTerminal *terminal;
 	gint cursor;
 
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
-	g_assert(GTK_IS_IM_CONTEXT(im_context));
-
 	gtk_im_context_get_preedit_string(im_context, &str, &attrs, &cursor);
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
@@ -3724,9 +3635,7 @@ #endif
 	 * for repainting. */
 	_vte_invalidate_cursor_once(terminal, FALSE);
 
-	if (terminal->pvt->im_preedit != NULL) {
-		g_free(terminal->pvt->im_preedit);
-	}
+	g_free(terminal->pvt->im_preedit);
 	terminal->pvt->im_preedit = str;
 
 	if (terminal->pvt->im_preedit_attrs != NULL) {
@@ -3742,19 +3651,13 @@ #endif
 /* Handle the toplevel being reconfigured. */
 static gboolean
 vte_terminal_configure_toplevel(GtkWidget *widget, GdkEventConfigure *event,
-				gpointer data)
+				VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		g_printerr("Top level parent configured.\n");
 	}
 #endif
-	g_assert(GTK_IS_WIDGET(widget));
-	g_assert(GTK_WIDGET_TOPLEVEL(widget));
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
 
 	if (terminal->pvt->bg_transparent) {
 		/* We have to repaint the entire window, because we don't get
@@ -3780,18 +3683,17 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
-	if (GTK_IS_WIDGET(old_toplevel)) {
-		g_signal_handlers_disconnect_by_func(G_OBJECT(old_toplevel),
-						     (gpointer)vte_terminal_configure_toplevel,
+	if (old_toplevel != NULL) {
+		g_signal_handlers_disconnect_by_func(old_toplevel,
+						     vte_terminal_configure_toplevel,
 						     terminal);
 	}
 
 	toplevel = gtk_widget_get_toplevel(widget);
-	if (GTK_IS_WIDGET(toplevel)) {
-		g_signal_connect(G_OBJECT(toplevel), "configure-event",
+	if (toplevel != NULL) {
+		g_signal_connect(toplevel, "configure-event",
 				 G_CALLBACK(vte_terminal_configure_toplevel),
 				 terminal);
 	}
@@ -3802,7 +3704,6 @@ static void
 vte_terminal_style_changed(GtkWidget *widget, GtkStyle *style, gpointer data)
 {
 	VteTerminal *terminal;
-	g_assert(VTE_IS_TERMINAL(widget));
 	if (!GTK_WIDGET_REALIZED(widget)) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_MISC)) {
@@ -3830,8 +3731,8 @@ add_cursor_timeout (VteTerminal *termina
 	GtkSettings *settings;
 
 	/* Setup cursor blink */
-	settings = gtk_widget_get_settings(GTK_WIDGET(terminal));
-	if (G_IS_OBJECT(settings)) {
+	settings = gtk_widget_get_settings(&terminal->widget);
+	if (settings != NULL) {
 		gint blink_cycle = 1000;
 		g_object_get(G_OBJECT(settings), "gtk-cursor-blink-time",
 			     &blink_cycle, NULL);
@@ -3841,7 +3742,7 @@ add_cursor_timeout (VteTerminal *termina
 	terminal->pvt->cursor_blink_time = 0;
 	terminal->pvt->cursor_blink_tag = g_timeout_add_full(G_PRIORITY_LOW,
 							     terminal->pvt->cursor_blink_timeout,
-							     vte_invalidate_cursor_periodic,
+							     (GSourceFunc)vte_invalidate_cursor_periodic,
 							     terminal,
 							     NULL);
 }
@@ -3876,8 +3777,6 @@ vte_terminal_key_press(GtkWidget *widget
 	GdkModifierType modifiers;
 	GtkWidgetClass *widget_class;
 
-	g_assert(widget != NULL);
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	/* First, check if GtkWidget's behavior already does something with
@@ -4302,7 +4201,6 @@ vte_same_class(VteTerminal *terminal, gl
 {
 	struct vte_charcell *pcell = NULL;
 	gboolean word_char;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if ((pcell = vte_terminal_find_charcell(terminal, acol, arow)) != NULL && !pcell->empty) {
 		word_char = vte_terminal_is_word_char(terminal, pcell->c);
 
@@ -4329,7 +4227,6 @@ vte_line_is_wrappable(VteTerminal *termi
 {
 	VteRowData *rowdata;
 	VteScreen *screen;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	screen = terminal->pvt->screen;
 	if (_vte_ring_contains(screen->row_data, row)) {
 		rowdata = _vte_ring_index(screen->row_data, VteRowData *, row);
@@ -4438,8 +4335,7 @@ vte_terminal_paste_cb(GtkClipboard *clip
 	VteTerminal *terminal;
 	gchar *paste, *p;
 	long length;
-	g_assert(VTE_IS_TERMINAL(data));
-	terminal = VTE_TERMINAL(data);
+	terminal = data;
 	if (text != NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
@@ -4478,8 +4374,6 @@ vte_terminal_send_mouse_button_internal(
 	unsigned char cb = 0, cx = 0, cy = 0;
 	char buf[LINE_MAX];
 
-	g_assert(VTE_IS_TERMINAL(terminal));
-
 	/* Encode the button information in cb. */
 	switch (button) {
 	case 0:			/* Release/no buttons. */
@@ -4576,8 +4470,6 @@ vte_terminal_maybe_send_mouse_drag(VteTe
 	unsigned char cb = 0, cx = 0, cy = 0;
 	char buf[LINE_MAX];
 
-	g_assert(VTE_IS_TERMINAL(terminal));
-
 	/* First determine if we even want to send notification. */
 	switch (event->type) {
 	case GDK_MOTION_NOTIFY:
@@ -4760,8 +4652,7 @@ static void
 vte_terminal_clear_cb(GtkClipboard *clipboard, gpointer owner)
 {
 	VteTerminal *terminal;
-	g_assert(VTE_IS_TERMINAL(owner));
-	terminal = VTE_TERMINAL(owner);
+	terminal = owner;
 	if (terminal->pvt->has_selection) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
@@ -4778,8 +4669,7 @@ vte_terminal_copy_cb(GtkClipboard *clipb
 		     guint info, gpointer owner)
 {
 	VteTerminal *terminal;
-	g_assert(VTE_IS_TERMINAL(owner));
-	terminal = VTE_TERMINAL(owner);
+	terminal = owner;
 	if (terminal->pvt->selection != NULL) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_SELECTION)) {
@@ -4859,8 +4749,6 @@ vte_terminal_get_text_range_maybe_wrappe
 	struct _VteCharAttributes attr;
 	struct vte_palette_entry fore, back, *palette;
 
-	g_assert(VTE_IS_TERMINAL(terminal));
-	g_assert(is_selected != NULL);
 	screen = terminal->pvt->screen;
 
 	if (attributes)
@@ -5109,7 +4997,7 @@ static GtkClipboard *
 vte_terminal_clipboard_get(VteTerminal *terminal, GdkAtom board)
 {
 	GdkDisplay *display;
-	display = gtk_widget_get_display(GTK_WIDGET(terminal));
+	display = gtk_widget_get_display(&terminal->widget);
 	return gtk_clipboard_get_for_display(display, board);
 }
 
@@ -5122,7 +5010,6 @@ vte_terminal_copy(VteTerminal *terminal,
 	static GtkTargetEntry *targets = NULL;
 	static gint n_targets = 0;
 
-	g_assert(VTE_IS_TERMINAL(terminal));
 	clipboard = vte_terminal_clipboard_get(terminal, board);
 
 	/* Chuck old selected text and retrieve the newly-selected text. */
@@ -5179,7 +5066,6 @@ static void
 vte_terminal_paste(VteTerminal *terminal, GdkAtom board)
 {
 	GtkClipboard *clipboard;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	clipboard = vte_terminal_clipboard_get(terminal, board);
 	if (clipboard != NULL) {
 #ifdef VTE_DEBUG
@@ -5660,18 +5546,13 @@ #endif
 }
 
 /* Autoscroll a bit. */
-static int
-vte_terminal_autoscroll(gpointer data)
+static gboolean
+vte_terminal_autoscroll(VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-	GtkWidget *widget;
 	gboolean extend = FALSE;
 	gdouble x, y, xmax, ymax;
 	glong adj;
 
-	terminal = VTE_TERMINAL(data);
-	widget = GTK_WIDGET(terminal);
-
 	/* Provide an immediate effect for mouse wigglers. */
 	if (terminal->pvt->mouse_last_y < 0) {
 		if (terminal->adjustment) {
@@ -5738,7 +5619,7 @@ vte_terminal_start_autoscroll(VteTermina
 		terminal->pvt->mouse_autoscroll_tag =
 			g_timeout_add_full(G_PRIORITY_LOW,
 					   1000 / terminal->row_count,
-					   vte_terminal_autoscroll,
+					   (GSourceFunc)vte_terminal_autoscroll,
 					   terminal,
 					   NULL);
 	}
@@ -5762,7 +5643,6 @@ vte_terminal_motion_notify(GtkWidget *wi
 	GdkModifierType modifiers;
 	gboolean event_mode;
 
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	event_mode = terminal->pvt->mouse_send_xy_on_click ||
@@ -5868,7 +5748,6 @@ vte_terminal_button_press(GtkWidget *wid
 	gboolean start_selecting = FALSE, extend_selecting = FALSE;
 	long cellx, celly;
 
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 	height = terminal->char_height;
 	width = terminal->char_width;
@@ -6061,7 +5940,6 @@ vte_terminal_button_release(GtkWidget *w
 	gboolean handled = FALSE;
 	gboolean event_mode;
 
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 	_vte_terminal_set_pointer_visible(terminal, TRUE);
 
@@ -6144,8 +6022,6 @@ vte_terminal_focus_in(GtkWidget *widget,
 {
 	VteTerminal *terminal;
 	GdkModifierType modifiers;
-	g_assert(GTK_IS_WIDGET(widget));
-	g_assert(VTE_IS_TERMINAL(widget));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		g_printerr("Focus in.\n");
@@ -6179,8 +6055,6 @@ vte_terminal_focus_out(GtkWidget *widget
 {
 	VteTerminal *terminal;
 	GdkModifierType modifiers;
-	g_assert(GTK_WIDGET(widget));
-	g_assert(VTE_IS_TERMINAL(widget));
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_EVENTS)) {
 		g_printerr("Focus out.\n");
@@ -6209,8 +6083,6 @@ static gint
 vte_terminal_visibility_notify(GtkWidget *widget, GdkEventVisibility *event)
 {
 	VteTerminal *terminal;
-	g_assert(GTK_WIDGET(widget));
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 	terminal->pvt->visibility_state = event->state;
 	if (terminal->pvt->visibility_state == GDK_VISIBILITY_UNOBSCURED)
@@ -6250,8 +6122,8 @@ vte_terminal_apply_metrics(VteTerminal *
 	}
 	/* Queue a resize if anything's changed. */
 	if (resize) {
-		if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
-			gtk_widget_queue_resize(GTK_WIDGET(terminal));
+		if (GTK_WIDGET_REALIZED(terminal)) {
+			gtk_widget_queue_resize(&terminal->widget);
 		}
 	}
 	/* Emit a signal that the font changed. */
@@ -6283,12 +6155,9 @@ vte_terminal_set_font_full(VteTerminal *
 			   const PangoFontDescription *font_desc,
 			   VteTerminalAntiAlias antialias)
 {
-	GtkWidget *widget;
 	PangoFontDescription *desc;
 
-	g_return_if_fail(terminal != NULL);
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-	widget = GTK_WIDGET(terminal);
 
 	terminal->pvt->has_fonts = TRUE;
 
@@ -6306,8 +6175,8 @@ #ifdef VTE_DEBUG
 		}
 #endif
 	} else {
-		gtk_widget_ensure_style(widget);
-		desc = pango_font_description_copy(widget->style->font_desc);
+		gtk_widget_ensure_style(&terminal->widget);
+		desc = pango_font_description_copy(terminal->widget.style->font_desc);
 		pango_font_description_set_family_static (desc, "monospace");
 
 #ifdef VTE_DEBUG
@@ -6421,7 +6290,6 @@ static void
 vte_terminal_refresh_size(VteTerminal *terminal)
 {
 	int rows, columns;
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if (terminal->pvt->pty_master != -1) {
 		/* Use an ioctl to read the size of the terminal. */
 		if (_vte_pty_get_size(terminal->pvt->pty_master, &columns, &rows) != 0) {
@@ -6479,19 +6347,14 @@ static void
 vte_terminal_handle_scroll(VteTerminal *terminal)
 {
 	long dy, adj;
-	GtkWidget *widget;
 	VteScreen *screen;
 
 	/* Sanity checks. */
-	g_assert(GTK_IS_WIDGET(terminal));
-	widget = GTK_WIDGET(terminal);
-	screen = terminal->pvt->screen;
-	if (GTK_WIDGET_REALIZED(widget) == FALSE) {
+	if (GTK_WIDGET_REALIZED(terminal) == FALSE) {
 		return;
 	}
 
-	/* This may generate multiple redraws, so freeze it while we do them. */
-	gdk_window_freeze_updates(widget->window);
+	screen = terminal->pvt->screen;
 
 	/* Read the new adjustment value and save the difference. */
 	adj = floor(gtk_adjustment_get_value(terminal->adjustment));
@@ -6514,9 +6377,6 @@ #ifdef VTE_DEBUG
 	      g_printerr("Not scrolling\n");
 	}
 #endif
-
-	/* Let the refreshing begin. */
-	gdk_window_thaw_updates(widget->window);
 }
 
 /* Set the adjustment objects used by the terminal widget. */
@@ -6524,7 +6384,6 @@ static void
 vte_terminal_set_scroll_adjustment(VteTerminal *terminal,
 				   GtkAdjustment *adjustment)
 {
-	g_assert(VTE_IS_TERMINAL(terminal));
 	if (adjustment != NULL) {
 		/* Add a reference to the new adjustment object. */
 		g_object_ref(adjustment);
@@ -6745,16 +6604,15 @@ vte_terminal_connect_xft_settings(VteTer
 {
 	GtkSettings *settings;
 	GObjectClass *klass;
-	gpointer func;
 
-	gtk_widget_ensure_style(GTK_WIDGET(terminal));
-	settings = gtk_widget_get_settings(GTK_WIDGET(terminal));
+	gtk_widget_ensure_style(&terminal->widget);
+	settings = gtk_widget_get_settings(&terminal->widget);
 	if (settings == NULL) {
 		return;
 	}
 
 	/* Check that the properties we're looking at are defined. */
-	klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
+	klass = G_OBJECT_GET_CLASS(settings);
 	if (g_object_class_find_property(klass, "gtk-xft-antialias") == NULL) {
 		return;
 	}
@@ -6762,23 +6620,13 @@ vte_terminal_connect_xft_settings(VteTer
 	/* If this is our first time in here, start listening for changes
 	 * to the Xft settings. */
 	if (terminal->pvt->connected_settings == NULL) {
+		GCallback func = G_CALLBACK(vte_terminal_fc_settings_changed);
 		terminal->pvt->connected_settings = settings;
-		func = (gpointer) vte_terminal_fc_settings_changed;
-		g_signal_connect(G_OBJECT(settings),
-				"notify::gtk-xft-antialias",
-				G_CALLBACK(func), terminal);
-		g_signal_connect(G_OBJECT(settings),
-				"notify::gtk-xft-hinting",
-				G_CALLBACK(func), terminal);
-		g_signal_connect(G_OBJECT(settings),
-				"notify::gtk-xft-hintstyle",
-				G_CALLBACK(func), terminal);
-		g_signal_connect(G_OBJECT(settings),
-				"notify::gtk-xft-rgba",
-				G_CALLBACK(func), terminal);
-		g_signal_connect(G_OBJECT(settings),
-				"notify::gtk-xft-dpi",
-				G_CALLBACK(func), terminal);
+		g_signal_connect(settings, "notify::gtk-xft-antialias", func, terminal);
+		g_signal_connect(settings, "notify::gtk-xft-hinting", func, terminal);
+		g_signal_connect(settings, "notify::gtk-xft-hintstyle", func, terminal);
+		g_signal_connect(settings, "notify::gtk-xft-rgba", func, terminal);
+		g_signal_connect(settings, "notify::gtk-xft-dpi", func, terminal);
 	}
 }
 
@@ -6788,14 +6636,12 @@ static void
 vte_terminal_disconnect_xft_settings(VteTerminal *terminal)
 {
 	GtkSettings *settings;
-	gpointer func;
 
 	if (terminal->pvt->connected_settings != NULL) {
 		settings = terminal->pvt->connected_settings;
-		func = (gpointer) vte_terminal_fc_settings_changed;
-		g_signal_handlers_disconnect_by_func(G_OBJECT(settings),
-						     func,
-						     terminal);
+		g_signal_handlers_disconnect_by_func(settings,
+				         vte_terminal_fc_settings_changed,
+					 terminal);
 		terminal->pvt->connected_settings = NULL;
 	}
 }
@@ -6803,9 +6649,7 @@ vte_terminal_disconnect_xft_settings(Vte
 static void
 _vte_terminal_codeset_changed_cb(struct _vte_iso2022_state *state, gpointer p)
 {
-	g_assert(VTE_IS_TERMINAL(p));
-	vte_terminal_set_encoding(VTE_TERMINAL(p),
-				  _vte_iso2022_state_get_codeset(state));
+	vte_terminal_set_encoding(p, _vte_iso2022_state_get_codeset(state));
 }
 
 /* Initialize the terminal widget after the base widget stuff is initialized.
@@ -6826,21 +6670,15 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(VTE_IS_TERMINAL(terminal));
-	widget = GTK_WIDGET(terminal);
-	GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS);
+	GTK_WIDGET_SET_FLAGS(terminal, GTK_CAN_FOCUS);
 
 	/* We do our own redrawing. */
-	gtk_widget_set_redraw_on_allocate (widget, FALSE);
+	gtk_widget_set_redraw_on_allocate (&terminal->widget, FALSE);
 
 	/* Set an adjustment for the application to use to control scrolling. */
 	adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 0, 0, 0));
 	vte_terminal_set_scroll_adjustment(terminal, adjustment);
 
-	/* Initialize the default titles. */
-	terminal->window_title = NULL;
-	terminal->icon_title = NULL;
-
 	/* Set up dummy metrics, value != 0 to avoid division by 0 */
 	terminal->char_width = 1;
 	terminal->char_height = 1;
@@ -6853,7 +6691,6 @@ #endif
 	/* We allocated zeroed memory, just fill in non-zero stuff. */
 
 	/* Load the termcap data and set up the emulation. */
-	memset(&pvt->flags, 0, sizeof(pvt->flags));
 	pvt->keypad_mode = VTE_KEYMODE_NORMAL;
 	pvt->cursor_mode = VTE_KEYMODE_NORMAL;
 	pvt->dec_saved = g_hash_table_new(g_direct_hash, g_direct_equal);
@@ -6934,11 +6771,11 @@ #endif
 	vte_terminal_match_hilite_clear(terminal);
 
 	/* Rendering data.  Try everything. */
-	pvt->draw = _vte_draw_new(GTK_WIDGET(terminal));
+	pvt->draw = _vte_draw_new(&terminal->widget);
 
 	/* The font description. */
 	pvt->fontantialias = VTE_ANTI_ALIAS_USE_DEFAULT;
-	gtk_widget_ensure_style(widget);
+	gtk_widget_ensure_style(&terminal->widget);
 	vte_terminal_connect_xft_settings(terminal);
 
 	/* Set up background information. */
@@ -6956,18 +6793,18 @@ #endif
 	pvt->visibility_state = GDK_VISIBILITY_UNOBSCURED;
 
 	/* Listen for hierarchy change notifications. */
-	g_signal_connect(G_OBJECT(terminal), "hierarchy-changed",
+	g_signal_connect(terminal, "hierarchy-changed",
 			 G_CALLBACK(vte_terminal_hierarchy_changed),
 			 NULL);
 
 	/* Listen for style changes. */
-	g_signal_connect(G_OBJECT(terminal), "style-set",
+	g_signal_connect(terminal, "style-set",
 			 G_CALLBACK(vte_terminal_style_changed),
 			 NULL);
 
 #ifdef VTE_DEBUG
 	/* In debuggable mode, we always do this. */
-	/* gtk_widget_get_accessible(GTK_WIDGET(terminal)); */
+	/* gtk_widget_get_accessible(&terminal->widget); */
 #endif
 }
 
@@ -6983,8 +6820,6 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(widget != NULL);
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	if (terminal->pvt->pty_master != -1) {
@@ -7026,9 +6861,6 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(widget != NULL);
-	g_assert(VTE_IS_TERMINAL(widget));
-
 	terminal = VTE_TERMINAL(widget);
 
 	snapped_to_bottom = (terminal->pvt->screen->insert_delta ==
@@ -7110,7 +6942,6 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	/* Load default fonts, if no fonts have been loaded. */
@@ -7127,14 +6958,10 @@ #endif
 
 /* Queue a background update. */
 static void
-root_pixmap_changed_cb(VteBg *bg, gpointer data)
+root_pixmap_changed_cb(VteBg *bg, VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-	if (VTE_IS_TERMINAL(data)) {
-		terminal = VTE_TERMINAL(data);
-		if (terminal->pvt->bg_transparent) {
-			vte_terminal_queue_background_update(terminal);
-		}
+	if (terminal->pvt->bg_transparent) {
+		vte_terminal_queue_background_update(terminal);
 	}
 }
 
@@ -7151,13 +6978,11 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(widget != NULL);
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	/* Disconnect from background-change events. */
 	bg = vte_bg_get_for_screen(gtk_widget_get_screen(widget));
-	g_signal_handlers_disconnect_by_func(G_OBJECT(bg),
+	g_signal_handlers_disconnect_by_func(bg,
 					     root_pixmap_changed_cb,
 					     widget);
 
@@ -7172,13 +6997,13 @@ #endif
 
 	/* Shut down input methods. */
 	if (terminal->pvt->im_context != NULL) {
-	        g_signal_handlers_disconnect_by_func (G_OBJECT(terminal->pvt->im_context), 
+	        g_signal_handlers_disconnect_by_func (terminal->pvt->im_context, 
 						      vte_terminal_im_preedit_changed,
 						      terminal);
 		vte_terminal_im_reset(terminal);
 		gtk_im_context_set_client_window(terminal->pvt->im_context,
 						 NULL);
-		g_object_unref(G_OBJECT(terminal->pvt->im_context));
+		g_object_unref(terminal->pvt->im_context);
 		terminal->pvt->im_context = NULL;
 	}
 	terminal->pvt->im_preedit_active = FALSE;
@@ -7195,13 +7020,12 @@ #endif
 	/* Clean up our draw structure. */
 	if (terminal->pvt->draw != NULL) {
 		_vte_draw_free(terminal->pvt->draw);
+		terminal->pvt->draw = NULL;
 	}
-	terminal->pvt->draw = NULL;
 	terminal->pvt->has_fonts = FALSE;
 
 	/* Unmap the widget if it hasn't been already. */
 	if (GTK_WIDGET_MAPPED(widget)) {
-	  
 		gtk_widget_unmap(widget);
 	}
 
@@ -7210,7 +7034,7 @@ #endif
 		/* detach style */
 		gtk_style_detach(widget->style);
 
-	        gdk_window_set_user_data(widget->window, NULL);
+		gdk_window_set_user_data(widget->window, NULL);
 		gdk_window_destroy(widget->window);
 		widget->window = NULL;
 	}
@@ -7254,7 +7078,6 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(VTE_IS_TERMINAL(object));
 	terminal = VTE_TERMINAL(object);
 	object_class = G_OBJECT_GET_CLASS(G_OBJECT(object));
 	widget_class = g_type_class_peek(GTK_TYPE_WIDGET);
@@ -7319,10 +7142,10 @@ #endif
 	}
 
 	/* Disconnect from toplevel window configure events. */
-	toplevel = gtk_widget_get_toplevel(GTK_WIDGET(object));
-	if ((toplevel != NULL) && (G_OBJECT(toplevel) != G_OBJECT(object))) {
+	toplevel = gtk_widget_get_toplevel(&terminal->widget);
+	if ((toplevel != NULL) && (G_OBJECT(toplevel) != object)) {
 		g_signal_handlers_disconnect_by_func(toplevel,
-						     (gpointer)vte_terminal_configure_toplevel,
+						     vte_terminal_configure_toplevel,
 						     terminal);
 	}
 
@@ -7350,7 +7173,7 @@ #endif
 	if (terminal->pvt->selection != NULL) {
 		clipboard = vte_terminal_clipboard_get(terminal,
 						       GDK_SELECTION_PRIMARY);
-		if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(terminal)) {
+		if (gtk_clipboard_get_owner(clipboard) == object) {
 			gtk_clipboard_set_text(clipboard,
 					       terminal->pvt->selection,
 					       -1);
@@ -7384,13 +7207,13 @@ #endif
 	terminal->pvt->outgoing_conv = ((VteConv) -1);
 
 	/* Stop listening for child-exited signals. */
-	if (VTE_IS_REAPER(terminal->pvt->pty_reaper)) {
+	if (terminal->pvt->pty_reaper != NULL) {
 		g_signal_handlers_disconnect_by_func(terminal->pvt->pty_reaper,
-						     (gpointer)vte_terminal_catch_child_exited,
+						     vte_terminal_catch_child_exited,
 						     terminal);
-		g_object_unref(G_OBJECT(terminal->pvt->pty_reaper));
+		g_object_unref(terminal->pvt->pty_reaper);
+		terminal->pvt->pty_reaper = NULL;
 	}
-	terminal->pvt->pty_reaper = NULL;
 
 	/* Stop processing input. */
 	vte_terminal_stop_processing (terminal);
@@ -7482,7 +7305,7 @@ #endif
 static void
 vte_terminal_realize(GtkWidget *widget)
 {
-	VteTerminal *terminal = NULL;
+	VteTerminal *terminal;
 	GdkWindowAttr attributes;
 	GdkPixmap *bitmap;
 	GdkColor black = {0,0,0}, color;
@@ -7495,13 +7318,11 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_assert(widget != NULL);
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	/* Create the draw structure if we don't already have one. */
 	if (terminal->pvt->draw == NULL) {
-		terminal->pvt->draw = _vte_draw_new(GTK_WIDGET(terminal));
+		terminal->pvt->draw = _vte_draw_new(&terminal->widget);
 	}
 
 	/* Create the stock cursors. */
@@ -7584,23 +7405,23 @@ #endif
 	 * "retrieve-surrounding" and "delete-surrounding" events? */
 	if (terminal->pvt->im_context != NULL) {
 		vte_terminal_im_reset(terminal);
-		g_object_unref(G_OBJECT(terminal->pvt->im_context));
+		g_object_unref(terminal->pvt->im_context);
 		terminal->pvt->im_context = NULL;
 	}
 	terminal->pvt->im_preedit_active = FALSE;
 	terminal->pvt->im_context = gtk_im_multicontext_new();
 	gtk_im_context_set_client_window(terminal->pvt->im_context,
 					 widget->window);
-	g_signal_connect(G_OBJECT(terminal->pvt->im_context), "commit",
-			 GTK_SIGNAL_FUNC(vte_terminal_im_commit), terminal);
-	g_signal_connect(G_OBJECT(terminal->pvt->im_context), "preedit-start",
-			 GTK_SIGNAL_FUNC(vte_terminal_im_preedit_start),
+	g_signal_connect(terminal->pvt->im_context, "commit",
+			 G_CALLBACK(vte_terminal_im_commit), terminal);
+	g_signal_connect(terminal->pvt->im_context, "preedit-start",
+			 G_CALLBACK(vte_terminal_im_preedit_start),
 			 terminal);
-	g_signal_connect(G_OBJECT(terminal->pvt->im_context), "preedit-changed",
-			 GTK_SIGNAL_FUNC(vte_terminal_im_preedit_changed),
+	g_signal_connect(terminal->pvt->im_context, "preedit-changed",
+			 G_CALLBACK(vte_terminal_im_preedit_changed),
 			 terminal);
-	g_signal_connect(G_OBJECT(terminal->pvt->im_context), "preedit-end",
-			 GTK_SIGNAL_FUNC(vte_terminal_im_preedit_end),
+	g_signal_connect(terminal->pvt->im_context, "preedit-end",
+			 G_CALLBACK(vte_terminal_im_preedit_end),
 			 terminal);
 	gtk_im_context_set_use_preedit(terminal->pvt->im_context, TRUE);
 
@@ -7617,11 +7438,11 @@ #endif
 									&black,
 									&black,
 									0, 0);
+	g_object_unref(bitmap);
 
 	/* Connect to background-change events. */
 	bg = vte_bg_get_for_screen(gtk_widget_get_screen(widget));
-	g_signal_connect(G_OBJECT(bg),
-			 "root-pixmap-changed",
+	g_signal_connect(bg, "root-pixmap-changed",
 			 G_CALLBACK(root_pixmap_changed_cb),
 			 terminal);
 
@@ -7629,8 +7450,6 @@ #endif
 	vte_terminal_background_update(terminal);
 	
 	gtk_style_attach(widget->style, widget->window);
-
-	g_object_unref(G_OBJECT(bitmap));
 }
 
 static void
@@ -7641,9 +7460,6 @@ vte_terminal_determine_colors(VteTermina
 			      gboolean cursor,
 			      int *fore, int *back)
 {
-	g_assert(fore != NULL);
-	g_assert(back != NULL);
-
 	/* Determine what the foreground and background colors for rendering
 	 * text should be.  If highlight is set and we have a highlight color,
 	 * use that scheme.  If cursor is set and we have a cursor color, use
@@ -9128,10 +8944,6 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	/* Make a few sanity checks. */
-	g_assert(widget != NULL);
-	g_assert(VTE_IS_TERMINAL(widget));
-	g_assert(area != NULL);
 	terminal = VTE_TERMINAL(widget);
 	
 	/* Update whole selection if terminal is in block mode. */
@@ -9241,7 +9053,7 @@ #endif
 								    cell->c,
 								    cell->columns));
 		}
-		if (GTK_WIDGET_HAS_FOCUS(GTK_WIDGET(terminal))) {
+		if (GTK_WIDGET_HAS_FOCUS(terminal)) {
 			selected = vte_cell_is_selected(terminal, col, drow,
 							NULL);
 			blink = terminal->pvt->cursor_blink_state ^
@@ -9415,15 +9227,14 @@ #endif
 static gint
 vte_terminal_expose(GtkWidget *widget, GdkEventExpose *event)
 {
-	g_assert(VTE_IS_TERMINAL(widget));
 	if (event->window == widget->window) {
-		if (GTK_WIDGET_REALIZED(widget) &&
-		    GTK_WIDGET_VISIBLE(widget) &&
-		    GTK_WIDGET_MAPPED(widget)) {
-			vte_terminal_paint(widget, &event->area);
+		if (GTK_WIDGET_DRAWABLE(widget)) {
+			VteTerminal *terminal;
+			terminal = VTE_TERMINAL(widget);
+			if (terminal->pvt->visibility_state != GDK_VISIBILITY_FULLY_OBSCURED) {
+				vte_terminal_paint(widget, &event->area);
+			}
 		}
-	} else {
-		g_assert_not_reached();
 	}
 	return FALSE;
 }
@@ -9438,7 +9249,6 @@ vte_terminal_scroll(GtkWidget *widget, G
 	GdkModifierType modifiers;
 	int button;
 
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	/* Read the modifiers. */
@@ -9500,7 +9310,7 @@ #endif
 	}
 
 	/* Perform a history scroll. */
-	adj = (VTE_TERMINAL(widget))->adjustment;
+	adj = terminal->adjustment;
 
 	switch (event->direction) {
 	case GDK_SCROLL_UP:
@@ -9527,7 +9337,6 @@ vte_terminal_get_accessible(GtkWidget *w
 	VteTerminal *terminal;
 	static gboolean first_time = TRUE;
 
-	g_assert(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
 	if (first_time) {
@@ -10214,28 +10023,22 @@ vte_terminal_im_append_menuitems(VteTerm
 {
 	GtkIMMulticontext *context;
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-	g_return_if_fail(GTK_WIDGET_REALIZED(GTK_WIDGET((terminal))));
+	g_return_if_fail(GTK_WIDGET_REALIZED(terminal));
 	context = GTK_IM_MULTICONTEXT(terminal->pvt->im_context);
 	gtk_im_multicontext_append_menuitems(context, menushell);
 }
 
 /* Set up whatever background we wanted. */
 static gboolean
-vte_terminal_background_update(gpointer data)
+vte_terminal_background_update(VteTerminal *terminal)
 {
-	VteTerminal *terminal;
-	GtkWidget *widget;
 	GdkColormap *colormap;
 	GdkColor bgcolor;
 	double saturation;
 
-	g_assert(VTE_IS_TERMINAL(data));
-	widget = GTK_WIDGET(data);
-	terminal = VTE_TERMINAL(data);
-
 	/* If we're not realized yet, don't worry about it, because we get
 	 * called when we realize. */
-	if (!GTK_WIDGET_REALIZED(widget)) {
+	if (!GTK_WIDGET_REALIZED(terminal)) {
 #ifdef VTE_DEBUG
 		if (_vte_debug_on(VTE_DEBUG_MISC)) {
 			g_printerr("Can not set background image without "
@@ -10256,12 +10059,12 @@ #endif
 	bgcolor.green = terminal->pvt->palette[VTE_DEF_BG].green;
 	bgcolor.blue = terminal->pvt->palette[VTE_DEF_BG].blue;
 	bgcolor.pixel = 0;
-	gtk_widget_ensure_style(widget);
-	colormap = gdk_gc_get_colormap(widget->style->fg_gc[GTK_WIDGET_STATE(widget)]);
+	gtk_widget_ensure_style(&terminal->widget);
+	colormap = gdk_gc_get_colormap(terminal->widget.style->fg_gc[GTK_WIDGET_STATE(terminal)]);
 	if (colormap) {
 		gdk_rgb_find_color(colormap, &bgcolor);
 	}
-	gdk_window_set_background(widget->window, &bgcolor);
+	gdk_window_set_background(terminal->widget.window, &bgcolor);
 	_vte_draw_set_background_color(terminal->pvt->draw, &bgcolor,
 				       terminal->pvt->bg_opacity);
 
@@ -10325,7 +10128,7 @@ vte_terminal_queue_background_update(Vte
 		terminal->pvt->bg_update_pending = TRUE;
 		terminal->pvt->bg_update_tag =
 				g_idle_add_full(VTE_FX_PRIORITY,
-						vte_terminal_background_update,
+						(GSourceFunc)vte_terminal_background_update,
 						terminal,
 						NULL);
 #ifdef VTE_DEBUG
@@ -10454,6 +10257,7 @@ void
 vte_terminal_set_background_image(VteTerminal *terminal, GdkPixbuf *image)
 {
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
+	g_return_if_fail(image==NULL || GDK_IS_PIXBUF(image));
 
 #ifdef VTE_DEBUG
 	if (_vte_debug_on(VTE_DEBUG_MISC)) {
@@ -10464,20 +10268,20 @@ #endif
 
 	/* Get a ref to the new image if there is one.  Do it here just in
 	 * case we're actually given the same one we're already using. */
-	if (GDK_IS_PIXBUF(image)) {
-		g_object_ref(G_OBJECT(image));
+	if (image != NULL) {
+		g_object_ref(image);
 	}
 
 	/* Unref the previous background image. */
-	if (GDK_IS_PIXBUF(terminal->pvt->bg_pixbuf)) {
-		g_object_unref(G_OBJECT(terminal->pvt->bg_pixbuf));
+	if (terminal->pvt->bg_pixbuf != NULL) {
+		g_object_unref(terminal->pvt->bg_pixbuf);
 	}
 
 	/* Clear a background file name, if one was set. */
-	if (terminal->pvt->bg_file) {
+	if (terminal->pvt->bg_file != NULL) {
 		g_free(terminal->pvt->bg_file);
+		terminal->pvt->bg_file = NULL;
 	}
-	terminal->pvt->bg_file = NULL;
 
 	/* Set the new background. */
 	terminal->pvt->bg_pixbuf = image;
@@ -10505,14 +10309,12 @@ #ifdef VTE_DEBUG
 	}
 #endif
 	/* Save this background type. */
-	if (terminal->pvt->bg_file) {
-		g_free(terminal->pvt->bg_file);
-	}
+	g_free(terminal->pvt->bg_file);
 	terminal->pvt->bg_file = path ? g_strdup(path) : NULL;
 
 	/* Turn off other background types. */
-	if (GDK_IS_PIXBUF(terminal->pvt->bg_pixbuf)) {
-		g_object_unref(G_OBJECT(terminal->pvt->bg_pixbuf));
+	if (terminal->pvt->bg_pixbuf != NULL) {
+		g_object_unref(terminal->pvt->bg_pixbuf);
 		terminal->pvt->bg_pixbuf = NULL;
 	}
 
@@ -10575,7 +10377,7 @@ vte_terminal_set_cursor_blinks(VteTermin
 	terminal->pvt->cursor_blinks = blink;
 
 	if (!GTK_WIDGET_REALIZED (terminal) ||
-	    !GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (terminal)))
+	    !GTK_WIDGET_HAS_FOCUS (terminal))
 		return;
 
 	if (blink)
@@ -10858,7 +10660,7 @@ vte_terminal_reset(VteTerminal *terminal
 	}
 	terminal->pvt->iso2022 = _vte_iso2022_state_new(NULL,
 							&_vte_terminal_codeset_changed_cb,
-							(gpointer)terminal);
+							terminal);
 	_vte_iso2022_state_set_codeset(terminal->pvt->iso2022,
 				       terminal->pvt->encoding);
 	/* Reset keypad/cursor/function key modes. */
@@ -11179,11 +10981,9 @@ vte_terminal_get_icon_title(VteTerminal 
 void
 vte_terminal_set_pty(VteTerminal *terminal, int pty_master)
 {
-       GtkWidget *widget;
-       int i;
+       guint i;
 
        g_return_if_fail(VTE_IS_TERMINAL(terminal));
-       widget = GTK_WIDGET(terminal);
 
        if (terminal->pvt->pty_master != -1) {
                _vte_pty_close(terminal->pvt->pty_master);
@@ -11194,7 +10994,9 @@ vte_terminal_set_pty(VteTerminal *termin
 
        /* Set the pty to be non-blocking. */
        i = fcntl(terminal->pvt->pty_master, F_GETFL);
-       fcntl(terminal->pvt->pty_master, F_SETFL, i | O_NONBLOCK);
+	   if ((i & O_NONBLOCK) == 0) {
+		   fcntl(terminal->pvt->pty_master, F_SETFL, i | O_NONBLOCK);
+	   }
 
        vte_terminal_set_size(terminal,
                              terminal->column_count,
diff --git a/src/vteaccess.c b/src/vteaccess.c
index 38d8f96..cb3e9d6 100644
--- a/src/vteaccess.c
+++ b/src/vteaccess.c
@@ -777,35 +777,35 @@ vte_terminal_initialize (AtkObject *obj,
 			  VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA,
 			  vte_terminal_accessible_new_private_data());
 
-	g_signal_connect(G_OBJECT(terminal), "text-inserted",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_text_modified),
+	g_signal_connect(terminal, "text-inserted",
+			 G_CALLBACK(vte_terminal_accessible_text_modified),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "text-deleted",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_text_modified),
+	g_signal_connect(terminal, "text-deleted",
+			 G_CALLBACK(vte_terminal_accessible_text_modified),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "text-modified",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_text_modified),
+	g_signal_connect(terminal, "text-modified",
+			 G_CALLBACK(vte_terminal_accessible_text_modified),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "text-scrolled",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_text_scrolled),
+	g_signal_connect(terminal, "text-scrolled",
+			 G_CALLBACK(vte_terminal_accessible_text_scrolled),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "cursor-moved",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_invalidate_cursor),
+	g_signal_connect(terminal, "cursor-moved",
+			 G_CALLBACK(vte_terminal_accessible_invalidate_cursor),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "window-title-changed",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_title_changed),
+	g_signal_connect(terminal, "window-title-changed",
+			 G_CALLBACK(vte_terminal_accessible_title_changed),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "focus-in-event",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_focus_in),
+	g_signal_connect(terminal, "focus-in-event",
+			 G_CALLBACK(vte_terminal_accessible_focus_in),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "focus-out-event",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_focus_out),
+	g_signal_connect(terminal, "focus-out-event",
+			 G_CALLBACK(vte_terminal_accessible_focus_out),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "visibility-notify-event",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_visibility_notify),
+	g_signal_connect(terminal, "visibility-notify-event",
+			 G_CALLBACK(vte_terminal_accessible_visibility_notify),
 			 obj);
-	g_signal_connect(G_OBJECT(terminal), "selection-changed",
-			 GTK_SIGNAL_FUNC(vte_terminal_accessible_selection_changed),
+	g_signal_connect(terminal, "selection-changed",
+			 G_CALLBACK(vte_terminal_accessible_selection_changed),
 			 obj);
 
 	if (GTK_IS_WIDGET((GTK_WIDGET(terminal))->parent)) {
@@ -875,47 +875,47 @@ #endif
 					     (gpointer*) &accessible->widget);
 	}
 	if (G_IS_OBJECT(accessible->widget)) {
-		g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+		g_signal_handlers_disconnect_matched(accessible->widget,
 						     G_SIGNAL_MATCH_FUNC |
 						     G_SIGNAL_MATCH_DATA,
 						     0, 0, NULL,
-						     (gpointer)vte_terminal_accessible_text_modified,
+						     vte_terminal_accessible_text_modified,
 						     object);
-		g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+		g_signal_handlers_disconnect_matched(accessible->widget,
 						     G_SIGNAL_MATCH_FUNC |
 						     G_SIGNAL_MATCH_DATA,
 						     0, 0, NULL,
-						     (gpointer)vte_terminal_accessible_text_scrolled,
+						     vte_terminal_accessible_text_scrolled,
 						     object);
-		g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+		g_signal_handlers_disconnect_matched(accessible->widget,
 						     G_SIGNAL_MATCH_FUNC |
 						     G_SIGNAL_MATCH_DATA,
 						     0, 0, NULL,
-						     (gpointer)vte_terminal_accessible_invalidate_cursor,
+						     vte_terminal_accessible_invalidate_cursor,
 						     object);
-		g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+		g_signal_handlers_disconnect_matched(accessible->widget,
 						     G_SIGNAL_MATCH_FUNC |
 						     G_SIGNAL_MATCH_DATA,
 						     0, 0, NULL,
-						     (gpointer)vte_terminal_accessible_title_changed,
+						     vte_terminal_accessible_title_changed,
 						     object);
-		g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+		g_signal_handlers_disconnect_matched(accessible->widget,
 						     G_SIGNAL_MATCH_FUNC |
 						     G_SIGNAL_MATCH_DATA,
 						     0, 0, NULL,
-						     (gpointer)vte_terminal_accessible_focus_in,
+						     vte_terminal_accessible_focus_in,
 						     object);
-		g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+		g_signal_handlers_disconnect_matched(accessible->widget,
 						     G_SIGNAL_MATCH_FUNC |
 						     G_SIGNAL_MATCH_DATA,
 						     0, 0, NULL,
-						     (gpointer)vte_terminal_accessible_focus_out,
+						     vte_terminal_accessible_focus_out,
 						     object);
-		g_signal_handlers_disconnect_matched(G_OBJECT(accessible->widget),
+		g_signal_handlers_disconnect_matched(accessible->widget,
 						     G_SIGNAL_MATCH_FUNC |
 						     G_SIGNAL_MATCH_DATA,
 						     0, 0, NULL,
-						     (gpointer)vte_terminal_accessible_visibility_notify,
+						     vte_terminal_accessible_visibility_notify,
 						     object);
 	}
 	priv = g_object_get_data(object,
diff --git a/src/vtedraw.c b/src/vtedraw.c
index dcc7c04..0426303 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -65,7 +65,7 @@ _vte_draw_new(GtkWidget *widget)
 
 	/* Create the structure. */
 	draw = g_slice_new0(struct _vte_draw);
-	g_object_ref(G_OBJECT(widget));
+	g_object_ref(widget);
 	draw->widget = widget;
 	draw->started = FALSE;
 
@@ -105,8 +105,8 @@ _vte_draw_free(struct _vte_draw *draw)
 	draw->impl = NULL;
 	draw->impl_data = NULL;
 
-	if (GTK_IS_WIDGET(draw->widget)) {
-		g_object_unref(G_OBJECT(draw->widget));
+	if (draw->widget != NULL) {
+		g_object_unref(draw->widget);
 		draw->widget = NULL;
 	}
 	draw->started = FALSE;
@@ -151,7 +151,7 @@ _vte_draw_start(struct _vte_draw *draw)
 	g_return_if_fail(GTK_WIDGET_REALIZED(draw->widget));
 	g_return_if_fail(draw->impl != NULL);
 	g_return_if_fail(draw->impl->start != NULL);
-	g_object_ref(G_OBJECT(draw->widget->window));
+	g_object_ref(draw->widget->window);
 	draw->impl->start(draw);
 	draw->started = TRUE;
 }
@@ -163,7 +163,7 @@ _vte_draw_end(struct _vte_draw *draw)
 	g_return_if_fail(draw->impl != NULL);
 	g_return_if_fail(draw->impl->end != NULL);
 	draw->impl->end(draw);
-	g_object_unref(G_OBJECT(draw->widget->window));
+	g_object_unref(draw->widget->window);
 	draw->started = FALSE;
 }
 
diff --git a/src/vtefc.c b/src/vtefc.c
index 90c8ca4..3b8c362 100644
--- a/src/vtefc.c
+++ b/src/vtefc.c
@@ -163,7 +163,7 @@ _vte_fc_transcribe_from_pango_font_descr
 				    _vte_fc_slant_from_pango_style(style));
 	}
 
-	g_object_unref(G_OBJECT(context));
+	g_object_unref(context);
 }
 
 static void
@@ -203,7 +203,7 @@ _vte_fc_defaults_from_gtk(GtkWidget *wid
 	}
 
 	/* Check that the properties we're looking at are defined. */
-	klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
+	klass = G_OBJECT_GET_CLASS(settings);
 	if (g_object_class_find_property(klass, "gtk-xft-antialias") == NULL) {
 		return;
 	}
@@ -496,25 +496,25 @@ _vte_fc_connect_settings_changes(GtkWidg
 	}
 
 	/* Check that the properties we're looking at are defined. */
-	klass = G_OBJECT_CLASS(GTK_SETTINGS_GET_CLASS(settings));
+	klass = G_OBJECT_GET_CLASS(settings);
 	if (g_object_class_find_property(klass, "gtk-xft-antialias") == NULL) {
 		return;
 	}
 
 	/* Start listening for changes to the fontconfig settings. */
-	g_signal_connect(G_OBJECT(settings),
+	g_signal_connect(settings,
 			 "notify::gtk-xft-antialias",
 			 G_CALLBACK(changed_cb), widget);
-	g_signal_connect(G_OBJECT(settings),
+	g_signal_connect(settings,
 			 "notify::gtk-xft-hinting",
 			 G_CALLBACK(changed_cb), widget);
-	g_signal_connect(G_OBJECT(settings),
+	g_signal_connect(settings,
 			 "notify::gtk-xft-hintstyle",
 			 G_CALLBACK(changed_cb), widget);
-	g_signal_connect(G_OBJECT(settings),
+	g_signal_connect(settings,
 			 "notify::gtk-xft-rgba",
 			 G_CALLBACK(changed_cb), widget);
-	g_signal_connect(G_OBJECT(settings),
+	g_signal_connect(settings,
 			 "notify::gtk-xft-dpi",
 			 G_CALLBACK(changed_cb), widget);
 }
@@ -531,7 +531,7 @@ _vte_fc_disconnect_settings_changes(GtkW
 	}
 
 	/* Stop listening for changes to the fontconfig settings. */
-	g_signal_handlers_disconnect_matched(G_OBJECT(settings),
+	g_signal_handlers_disconnect_matched(settings,
 					     G_SIGNAL_MATCH_FUNC |
 					     G_SIGNAL_MATCH_DATA,
 					     0, 0, NULL,
diff --git a/src/vteft2.c b/src/vteft2.c
index 2c810ab..1bf9ded 100644
--- a/src/vteft2.c
+++ b/src/vteft2.c
@@ -76,8 +76,8 @@ _vte_ft2_destroy(struct _vte_draw *draw)
 		_vte_rgb_buffer_free(data->rgb);
 	}
 	memset(&data->color, 0, sizeof(data->color));
-	if (GDK_IS_PIXBUF(data->pixbuf)) {
-		g_object_unref(G_OBJECT(data->pixbuf));
+	if (data->pixbuf != NULL) {
+		g_object_unref(data->pixbuf);
 		data->pixbuf = NULL;
 	}
 	data->scrollx = data->scrolly = 0;
@@ -174,8 +174,8 @@ _vte_ft2_set_background_image(struct _vt
 	bgpixbuf = vte_bg_get_pixbuf(vte_bg_get_for_screen(screen),
 				     type, pixbuf, file,
 				     color, saturation);
-	if (GDK_IS_PIXBUF(data->pixbuf)) {
-		g_object_unref(G_OBJECT(data->pixbuf));
+	if (data->pixbuf != NULL) {
+		g_object_unref(data->pixbuf);
 	}
 	data->pixbuf = bgpixbuf;
 }
@@ -200,7 +200,7 @@ _vte_ft2_clear(struct _vte_draw *draw,
 	struct _vte_ft2_data *data;
 	data = (struct _vte_ft2_data*) draw->impl_data;
 
-	if (GDK_IS_PIXBUF(data->pixbuf)) {
+	if (data->pixbuf != NULL) {
 		/* Tile a pixbuf in. */
 		_vte_rgb_draw_pixbuf(data->rgb, x, y, width, height,
 				     data->pixbuf,
diff --git a/src/vtegl.c b/src/vtegl.c
index f48f2ed..2450c63 100644
--- a/src/vtegl.c
+++ b/src/vtegl.c
@@ -178,8 +178,8 @@ _vte_gl_destroy(struct _vte_draw *draw)
 	_vte_glyph_cache_free(data->cache);
 	data->cache = NULL;
 
-	if (GDK_IS_PIXBUF(data->bgpixbuf)) {
-		g_object_unref(G_OBJECT(data->bgpixbuf));
+	if (data->bgpixbuf != NULL) {
+		g_object_unref(data->bgpixbuf);
 	}
 	data->bgpixbuf = NULL;
 
@@ -285,8 +285,8 @@ _vte_gl_set_background_image(struct _vte
 	bgpixbuf = vte_bg_get_pixbuf(vte_bg_get_for_screen(screen),
 			 	     type, pixbuf, file,
 				     tint, saturation);
-	if (GDK_IS_PIXBUF(data->bgpixbuf)) {
-		g_object_unref(G_OBJECT(data->bgpixbuf));
+	if (data->bgpixbuf != NULL) {
+		g_object_unref(data->bgpixbuf);
 	}
 	data->bgpixbuf = bgpixbuf;
 }
@@ -308,7 +308,7 @@ _vte_gl_clear(struct _vte_draw *draw, gi
 
 	glXMakeCurrent(display, data->glwindow, data->context);
 
-	if (GDK_IS_PIXBUF(data->bgpixbuf)) {
+	if (data->bgpixbuf != NULL) {
 		pixbufw = gdk_pixbuf_get_width(data->bgpixbuf);
 		pixbufh = gdk_pixbuf_get_height(data->bgpixbuf);
 	} else {
diff --git a/src/vtepango.c b/src/vtepango.c
index 3a6676c..3210dda 100644
--- a/src/vtepango.c
+++ b/src/vtepango.c
@@ -77,8 +77,8 @@ _vte_pango_destroy(struct _vte_draw *dra
 
 	data->scrollx = data->scrolly = 0;
 
-	if (GDK_IS_PIXMAP(data->pixmap)) {
-		g_object_unref(G_OBJECT(data->pixmap));
+	if (data->pixmap != NULL) {
+		g_object_unref(data->pixmap);
 		data->pixmap = NULL;
 		data->pixmapw = data->pixmaph = 0;
 	}
@@ -86,16 +86,16 @@ _vte_pango_destroy(struct _vte_draw *dra
 		pango_font_description_free(data->font);
 		data->font = NULL;
 	}
-	if (PANGO_IS_LAYOUT(data->layout)) {
-		g_object_unref(G_OBJECT(data->layout));
+	if (data->layout != NULL) {
+		g_object_unref(data->layout);
 		data->layout = NULL;
 	}
-	if (PANGO_IS_CONTEXT(data->ctx)) {
-		g_object_unref(G_OBJECT(data->ctx));
+	if (data->ctx != NULL) {
+		g_object_unref(data->ctx);
 		data->ctx = NULL;
 	}
-	if (GDK_IS_GC(data->gc)) {
-		g_object_unref(G_OBJECT(data->gc));
+	if (data->gc != NULL) {
+		g_object_unref(data->gc);
 		data->gc = NULL;
 	}
 
@@ -126,21 +126,21 @@ _vte_pango_start(struct _vte_draw *draw)
 
 	screen = gdk_drawable_get_screen(draw->widget->window);
 	ctx = gdk_pango_context_get_for_screen(screen);
-	if (PANGO_IS_CONTEXT(data->ctx)) {
-		g_object_unref(G_OBJECT(data->ctx));
+	if (data->ctx != NULL) {
+		g_object_unref(data->ctx);
 	}
 	data->ctx = ctx;
 
-	if (PANGO_IS_LAYOUT(data->layout)) {
-		g_object_unref(G_OBJECT(data->layout));
+	if (data->layout != NULL) {
+		g_object_unref(data->layout);
 	}
 	data->layout = pango_layout_new(data->ctx);
-	if (data->font) {
+	if (data->font != NULL) {
 		pango_layout_set_font_description(data->layout, data->font);
 	}
 
-	if (GDK_IS_GC(data->gc)) {
-		g_object_unref(G_OBJECT(data->gc));
+	if (data->gc != NULL) {
+		g_object_unref(data->gc);
 	}
 	data->gc = gdk_gc_new(draw->widget->window);
 
@@ -154,18 +154,18 @@ _vte_pango_end(struct _vte_draw *draw)
 	struct _vte_pango_data *data;
 	data = (struct _vte_pango_data*) draw->impl_data;
 
-	if (GDK_IS_GC(data->gc)) {
-		g_object_unref(G_OBJECT(data->gc));
+	if (data->gc != NULL) {
+		g_object_unref(data->gc);
 	}
 	data->gc = NULL;
 
-	if (PANGO_IS_LAYOUT(data->layout)) {
-		g_object_unref(G_OBJECT(data->layout));
+	if (data->layout != NULL) {
+		g_object_unref(data->layout);
 	}
 	data->layout = NULL;
 
-	if (PANGO_IS_CONTEXT(data->ctx)) {
-		g_object_unref(G_OBJECT(data->ctx));
+	if (data->ctx != NULL) {
+		g_object_unref(data->ctx);
 	}
 	data->ctx = NULL;
 }
@@ -197,8 +197,8 @@ _vte_pango_set_background_image(struct _
 				   type, pixbuf, file,
 				   color, saturation,
 				   _vte_draw_get_colormap(draw, TRUE));
-	if (GDK_IS_PIXMAP(data->pixmap)) {
-		g_object_unref(G_OBJECT(data->pixmap));
+	if (data->pixmap != NULL) {
+		g_object_unref(data->pixmap);
 	}
 	data->pixmap = NULL;
 	data->pixmapw = data->pixmaph = 0;
@@ -331,8 +331,8 @@ #ifdef VTE_DEBUG
 	}
 #endif
 
-	g_object_unref(G_OBJECT(layout));
-	g_object_unref(G_OBJECT(ctx));
+	g_object_unref(layout);
+	g_object_unref(ctx);
 }
 
 static int
diff --git a/src/vtepangox.c b/src/vtepangox.c
index 4f43e2f..c3a2730 100644
--- a/src/vtepangox.c
+++ b/src/vtepangox.c
@@ -83,8 +83,8 @@ _vte_pango_x_destroy(struct _vte_draw *d
 
 	data->scrollx = data->scrolly = 0;
 
-	if (GDK_IS_PIXMAP(data->pixmap)) {
-		g_object_unref(G_OBJECT(data->pixmap));
+	if (data->pixmap != NULL) {
+		g_object_unref(data->pixmap);
 		data->pixmap = NULL;
 		data->pixmapw = data->pixmaph = 0;
 	}
@@ -92,16 +92,16 @@ _vte_pango_x_destroy(struct _vte_draw *d
 		pango_font_description_free(data->font);
 		data->font = NULL;
 	}
-	if (PANGO_IS_LAYOUT(data->layout)) {
-		g_object_unref(G_OBJECT(data->layout));
+	if (data->layout != NULL) {
+		g_object_unref(data->layout);
 		data->layout = NULL;
 	}
-	if (GDK_IS_GC(data->gc)) {
-		g_object_unref(G_OBJECT(data->gc));
+	if (data->gc != NULL) {
+		g_object_unref(data->gc);
 		data->gc = NULL;
 	}
-	if (PANGO_IS_CONTEXT(data->ctx)) {
-		g_object_unref(G_OBJECT(data->ctx));
+	if (data->ctx != NULL) {
+		g_object_unref(data->ctx);
 		data->ctx = NULL;
 	}
 
@@ -133,22 +133,22 @@ _vte_pango_x_start(struct _vte_draw *dra
 	data = (struct _vte_pango_x_data*) draw->impl_data;
 
 	display = gdk_x11_drawable_get_xdisplay(draw->widget->window);
-	if (PANGO_IS_CONTEXT(data->ctx)) {
-		g_object_unref(G_OBJECT(data->ctx));
+	if (data->ctx != NULL) {
+		g_object_unref(data->ctx);
 	}
 	data->ctx = pango_x_get_context(display);
 
-	if (PANGO_IS_LAYOUT(data->layout)) {
-		g_object_unref(G_OBJECT(data->layout));
+	if (data->layout != NULL) {
+		g_object_unref(data->layout);
 	}
 	data->layout = pango_layout_new(data->ctx);
 
-	if (data->font) {
+	if (data->font != NULL) {
 		pango_layout_set_font_description(data->layout, data->font);
 	}
 
-	if (GDK_IS_GC(data->gc)) {
-		g_object_unref(G_OBJECT(data->gc));
+	if (data->gc != NULL) {
+		g_object_unref(data->gc);
 	}
 	data->gc = gdk_gc_new(draw->widget->window);
 
@@ -172,18 +172,18 @@ _vte_pango_x_end(struct _vte_draw *draw)
 	data->x_offs = 0;
 	data->y_offs = 0;
 
-	if (PANGO_IS_LAYOUT(data->layout)) {
-		g_object_unref(G_OBJECT(data->layout));
+	if (data->layout != NULL) {
+		g_object_unref(data->layout);
 	}
 	data->layout = NULL;
 
-	if (GDK_IS_GC(data->gc)) {
-		g_object_unref(G_OBJECT(data->gc));
+	if (data->gc != NULL) {
+		g_object_unref(data->gc);
 	}
 	data->gc = NULL;
 
-	if (PANGO_IS_CONTEXT(data->ctx)) {
-		g_object_unref(G_OBJECT(data->ctx));
+	if (data->ctx != NULL) {
+		g_object_unref(data->ctx);
 	}
 	data->ctx = NULL;
 }
@@ -215,12 +215,12 @@ _vte_pango_x_set_background_image(struct
 				   type, pixbuf, file,
 				   color, saturation,
 				   _vte_draw_get_colormap(draw, TRUE));
-	if (data->pixmap) {
-		g_object_unref(G_OBJECT(data->pixmap));
+	if (data->pixmap != NULL) {
+		g_object_unref(data->pixmap);
 	}
 	data->pixmap = NULL;
 	data->pixmapw = data->pixmaph = 0;
-	if (pixmap) {
+	if (pixmap != NULL) {
 		data->pixmap = pixmap;
 		gdk_drawable_get_size(pixmap, &data->pixmapw, &data->pixmaph);
 	}
@@ -291,8 +291,8 @@ _vte_pango_x_set_text_font(struct _vte_d
 	data = (struct _vte_pango_x_data*) draw->impl_data;
 
 	display = gdk_x11_display_get_xdisplay(gtk_widget_get_display(draw->widget));
-	if (PANGO_IS_CONTEXT(data->ctx)) {
-		g_object_unref(G_OBJECT(data->ctx));
+	if (data->ctx != NULL) {
+		g_object_unref(data->ctx);
 	}
 	ctx = pango_x_get_context(display);
 
@@ -347,8 +347,8 @@ #ifdef VTE_DEBUG
 			draw->width, draw->height, draw->ascent);
 	}
 #endif
-	g_object_unref(G_OBJECT(layout));
-	g_object_unref(G_OBJECT(ctx));
+	g_object_unref(layout);
+	g_object_unref(ctx);
 }
 
 static int
diff --git a/src/vterdb.c b/src/vterdb.c
index 4b7f629..7d494f0 100644
--- a/src/vterdb.c
+++ b/src/vterdb.c
@@ -58,13 +58,13 @@ _vte_rdb_get(GtkWidget *widget, gboolean
 	GdkDisplay *display;
 	GdkScreen *screen;
 
-	if (GTK_IS_WIDGET(widget)) {
+	if (widget != NULL) {
 		display = gtk_widget_get_display(widget);
 	} else {
 		display = gdk_display_get_default();
 	}
 
-	if (GTK_IS_WIDGET(widget) &&
+	if (widget != NULL &&
 	    gtk_widget_has_screen(widget) &&
 	    screen_setting) {
 		screen = gtk_widget_get_screen(widget);
diff --git a/src/vteseq.c b/src/vteseq.c
index 15c850e..b60c7a1 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -336,12 +336,10 @@ vte_sequence_handler_multiple(VteTermina
 static gboolean
 vte_sequence_handler_scroll_up_or_down(VteTerminal *terminal, int scroll_amount)
 {
-	GtkWidget *widget;
 	VteRowData *row;
 	long start, end, i;
 	VteScreen *screen;
 
-	widget = GTK_WIDGET(terminal);
 	screen = terminal->pvt->screen;
 
 	if (screen->scrolling_restricted) {
@@ -458,15 +456,15 @@ #endif
 			if (strcmp(signal, "window") == 0) {
 				g_free(terminal->window_title);
 				terminal->window_title = g_strdup(validated);
-				if (GTK_WIDGET (terminal)->window)
-					gdk_window_set_title (GTK_WIDGET (terminal)->window, validated);
+				if (terminal->widget.window)
+					gdk_window_set_title (terminal->widget.window, validated);
 				vte_terminal_emit_window_title_changed(terminal);
 			} else
 			if (strcmp(signal, "icon") == 0) {
 				g_free (terminal->icon_title);
 				terminal->icon_title = g_strdup(validated);
-				if (GTK_WIDGET (terminal)->window)
-					gdk_window_set_icon_name (GTK_WIDGET (terminal)->window, validated);
+				if (terminal->widget.window)
+					gdk_window_set_icon_name (terminal->widget.window, validated);
 				vte_terminal_emit_icon_title_changed(terminal);
 			}
 			g_free(validated);
@@ -1035,7 +1033,7 @@ vte_terminal_beep(VteTerminal *terminal)
 	GdkDisplay *display;
 
 	g_assert(VTE_IS_TERMINAL(terminal));
-	display = gtk_widget_get_display(GTK_WIDGET(terminal));
+	display = gtk_widget_get_display(&terminal->widget);
 	gdk_display_beep(display);
 }
 
@@ -1653,11 +1651,9 @@ vte_sequence_handler_do(VteTerminal *ter
 			GQuark match_quark,
 			GValueArray *params)
 {
-	GtkWidget *widget;
 	long start, end;
 	VteScreen *screen;
 
-	widget = GTK_WIDGET(terminal);
 	screen = terminal->pvt->screen;
 
 	if (screen->scrolling_restricted) {
@@ -2261,12 +2257,10 @@ vte_sequence_handler_sf(VteTerminal *ter
 			GQuark match_quark,
 			GValueArray *params)
 {
-	GtkWidget *widget;
 	VteRowData *row;
 	long start, end;
 	VteScreen *screen;
 
-	widget = GTK_WIDGET(terminal);
 	screen = terminal->pvt->screen;
 
 	if (screen->scrolling_restricted) {
@@ -2297,7 +2291,6 @@ vte_sequence_handler_sf(VteTerminal *ter
 				/* This may generate multiple redraws, so
 				 * disable fast scrolling for now. */
 				terminal->pvt->scroll_lock_count++;
-				gdk_window_freeze_updates(widget->window);
 				/* Force the areas below the region to be
 				 * redrawn -- they've moved. */
 				_vte_terminal_scroll_region(terminal, start,
@@ -2306,7 +2299,6 @@ vte_sequence_handler_sf(VteTerminal *ter
 				_vte_terminal_ensure_cursor(terminal, FALSE);
 				_vte_terminal_adjust_adjustments(terminal, TRUE);
 				/* Allow updates again. */
-				gdk_window_thaw_updates(widget->window);
 				terminal->pvt->scroll_lock_count--;
 			} else {
 				/* If we're at the bottom of the scrolling
@@ -2317,7 +2309,6 @@ vte_sequence_handler_sf(VteTerminal *ter
 				/* This may generate multiple redraws, so
 				 * disable fast scrolling for now. */
 				terminal->pvt->scroll_lock_count++;
-				gdk_window_freeze_updates(widget->window);
 				/* Update the display. */
 				_vte_terminal_scroll_region(terminal, start,
 							   end - start + 1, -1);
@@ -2325,7 +2316,6 @@ vte_sequence_handler_sf(VteTerminal *ter
 						      0, terminal->column_count,
 						      end - 2, 2);
 				/* Allow updates again. */
-				gdk_window_thaw_updates(widget->window);
 				terminal->pvt->scroll_lock_count--;
 			}
 		} else {
@@ -2432,11 +2422,9 @@ vte_sequence_handler_sr(VteTerminal *ter
 			GQuark match_quark,
 			GValueArray *params)
 {
-	GtkWidget *widget;
 	long start, end;
 	VteScreen *screen;
 
-	widget = GTK_WIDGET(terminal);
 	screen = terminal->pvt->screen;
 
 	if (screen->scrolling_restricted) {
@@ -2677,7 +2665,7 @@ vte_sequence_handler_vb(VteTerminal *ter
 	GtkWidget *widget;
 	gint width, height, state;
 
-	widget = GTK_WIDGET(terminal);
+	widget = &terminal->widget;
 	if (GTK_WIDGET_REALIZED(widget)) {
 		gdk_drawable_get_size(widget->window, &width, &height);
 		state = GTK_WIDGET_STATE(widget);
@@ -3773,7 +3761,7 @@ vte_sequence_handler_window_manipulation
 	long param, arg1, arg2;
 	guint width, height, i;
 
-	widget = GTK_WIDGET(terminal);
+	widget = &terminal->widget;
 	screen = terminal->pvt->screen;
 
 	for (i = 0; ((params != NULL) && (i < params->n_values)); i++) {
diff --git a/src/vteskel.c b/src/vteskel.c
index 214fbe5..5718d0f 100644
--- a/src/vteskel.c
+++ b/src/vteskel.c
@@ -67,8 +67,8 @@ _vte_skel_destroy(struct _vte_draw *draw
 
 	data->scrollx = data->scrolly = 0;
 
-	if (GDK_IS_PIXMAP(data->pixmap)) {
-		g_object_unref(G_OBJECT(data->pixmap));
+	if (data->pixmap != NULL) {
+		g_object_unref(data->pixmap);
 		data->pixmap = NULL;
 		data->pixmapw = data->pixmaph = 0;
 	}
diff --git a/src/vtetree.c b/src/vtetree.c
index fc08a78..c2b8054 100644
--- a/src/vtetree.c
+++ b/src/vtetree.c
@@ -23,7 +23,7 @@ #include "vtetree.h"
 VteTree *
 _vte_tree_new(GCompareFunc key_compare_func)
 {
-  VteTree *tree = g_new0 (VteTree, 1);
+  VteTree *tree = g_slice_new0 (VteTree);
   tree->tree = g_tree_new (key_compare_func);
   return tree;
 }
@@ -32,7 +32,7 @@ void 
 _vte_tree_destroy(VteTree *tree)
 {
   g_tree_destroy (tree->tree);
-  g_free (tree);
+  g_slice_free (VteTree, tree);
 }
 
 void 
diff --git a/src/vtexft.c b/src/vtexft.c
index d02055b..2126d23 100644
--- a/src/vtexft.c
+++ b/src/vtexft.c
@@ -434,11 +434,11 @@ _vte_xft_set_background_image(struct _vt
 	pixmap = vte_bg_get_pixmap(vte_bg_get_for_screen(screen), type,
 				   pixbuf, file, color, saturation,
 				   _vte_draw_get_colormap(draw, TRUE));
-	if (GDK_IS_PIXMAP(data->pixmap)) {
-		g_object_unref(G_OBJECT(data->pixmap));
+	if (data->pixmap != NULL) {
+		g_object_unref(data->pixmap);
 	}
 	data->pixmap = NULL;
-	if (GDK_IS_PIXMAP(pixmap)) {
+	if (pixmap != NULL) {
 		data->pixmap = pixmap;
 		data->xpixmap = gdk_x11_drawable_get_xid(pixmap);
 		gdk_drawable_get_size(pixmap, &data->pixmapw, &data->pixmaph);
@@ -456,7 +456,7 @@ _vte_xft_clear(struct _vte_draw *draw,
 
 	data = (struct _vte_xft_data*) draw->impl_data;
 
-	if (!GDK_IS_PIXMAP(data->pixmap) ||
+	if (data->pixmap == NULL ||
 	    (data->pixmapw <= 0) ||
 	    (data->pixmaph <= 0)) {
 		rcolor.red = data->color.red * data->opacity / 0xffff;
