Improved the way that the source dir is found