core: clear objects in dispose() else we could crash later (rh #1051727)

Also use g_clear_object() on other places to simplify the code.

https://bugzilla.redhat.com/show_bug.cgi?id=1051727