Fixing log.c, and finally reworked black magic in cfg.c