Fix problems occured when specifying directories