added sys/stat.h for umask()
fix params to cwrap()