Bug fix: don't take cfg[1] if cfg[0] is NULL, and so on.