Moved file related functions to own file