Create file settings and cleanup

copied various functions from (my local) sp_fn.R