Converting all routines to use black magic in cfg.c