Finished change of functions structure. Needs to review tests