Fix dirname bug and directory existance in parse.py