Replaced setgid() calls with setegid() so that it works with dot