Add input/outpur dir checks - fix a couple bugs