Fixing errors caused by directory not existing