Bug fixes to be able to run scripts on SGE