Added path checks and fixes for running script on Ubuntu.