Added docstrings and better commenting to fd.py