Almost done with refactor of fd.c