I would guess fog_directory needs encoding here and maybe the other uses in this function