insert_directory improvements