Added file functions and soem more cleanup