avoid using the basename to create temp files. Move invariant strings to higher in the application.