Using FileUtils API rather than sh for chmod-ing
Using Ruby chdir instead of executing everything as sh