Re-wrote filesystem handling code