Error checking and helpful info for users

Thanks so much for great code.

I made some changes for internal consumption and thought to contribute back.

Error checking for no role specified, provide useful help message.
Changed the temporary filename to start with a dot and use the process id, so that it does not conflict with potential other filenames.