Fix wdir calculation