More robust folder handling.