Merge from upstream

@apartmentlist/iosmobile 

merge upstream changes, then re-apply glib's change.