Added primarygroup/gid types and cleaned up code