Changed the way current directory is handles

After starting to use os.chdir before script execution,
os.path.realpath started returning some odd values so
all file references are based on os.getcwd after os.chdir
is called