Fixed crash and limit the number of variables in a pattern.