Added ability to change source and working directory as well as some logic for that.