ported FAC generator. unit test succeeds, execution in fg does not crash.