Merge custom_0.16 changes to 0.17 branch