Fixed misnamed variables, due to changing names.

Also moved the base path prepending into a separate function.