Refactored code, added quotes for variables.

Hi, thank you for a great tool. I did some refactoring of the code to be more readable.
`-f` isn't supported on BSD/OS X