refine local compat fixes, sync with upstream