Changed path.exists to fs.exists, to be compatible with node >v0.7. Also supporting backwards-compatibility.