added includes for 'getpid()'
used 'expanduser' to specify full pathnames