adds directory checks before calls to rm. adds sane default settings for build environment variables.
fixes directory checks