Factored out some common code
Renamed one parameter
Renamed one function
Moved checking for use of filereadable()
Better handling of Windows paths