Rewrote recursive function
added the stat library
Finished debugging code and fixed segmentation faults.