Added better error handling when creating dirs