Rename function for clarity.
Reorder some parameters.
Fix array length warning.
Add missing paths if necessary.
Fix parameter warning.