Adding better directory checking
Handling non-existent paths more gracefully