Correct some bugs and verified that the output directory flag works
Correct some bugs and verified that the output directory flag works

robertmaynard/Sandbox,robertmaynard/Sandbox,robertmaynard/Sandbox,robertmaynard/Sandbox