log.c: More bug fixes