core: Use g_clear_error()/g_clear_object()/g_list_free_full()

Simplify cleanup functions by relying on the NULL-safe versions of
g_error_free()/g_object_unref() and free lists and their elements in a
single pass.

https://bugzilla.gnome.org/show_bug.cgi?id=706495