Backport devel/libthrift fixes from trunk.