Separating function building from structure.

Refactored code to remove data that is only used to build the function
trees from Functions.