g_close() is only available in select versions of glib; fix up non-standard use of glib/cerr to report errors and other related mess