Updated remote execution check, and moved PWD stuff to separate file