Fixed TypeError and added 'gid' option