Implements part of do_bgfg