reduce variables and add const char* to insert_pathl.
remove unused variables