Adopt some changes from gf branch