Consistently get folder name

We got different results if the folder was given with or without the
trailing slash.
Also clean up variable names and give correct help.