Fix directory handling