Use g_clear_object where appropriate

GObject has a method called g_clear_object that decreases the reference
count and sets the pointer to NULL at the same time. Use it instead of
g_object_unref directly.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>