sync with upstream
patched to build with new glib