s/ifdef/if defined()
use application directory in path names
output stdout and stderr to temp files for debugging purposes