Apply bug 981029 changes for API compat
Partialy apply bug 980493 changes
Fixed build bustage