Rewrite of genform and gensearch