backport fixes and cleanups from 9front