diff --git a/06-hash/hash.tex b/06-hash/hash.tex
index e7248ea951616781a33832d12399d358234ebf83..4b2ad1f1ecb26ab48cb4bd58af8544ff0a62a1c0 100644
--- a/06-hash/hash.tex
+++ b/06-hash/hash.tex
@@ -39,6 +39,16 @@ Occasionally, we are not interested in the concrete value of~$c$,
 so we simply say that the family is \em{universal.}
 }
 
+\note{
+We will assume that a~function can be chosen from the family uniformly
+at random in constant time. Once chosen, it can be evaluated for any~$x$
+in constant time. Typically, we define a~single parametrized function $h_a(x)$
+and let the family $\cal H$ consist of all~$h_a$ for all possible choices of
+the parameter~$a$. Picking a~random $h\in{\cal H}$ is therefore implemented
+by picking a~random~$a$. Technically, this makes~$\cal H$ a~multi-set, since
+different values of~$a$ may lead to the same function~$h$.
+}
+
 \theorem{Let $\cal H$ be a~$c$-universal family of functions from~$\Uu$ to~$[m]$,
 $X=\{x_1,\ldots,x_n\} \subseteq \Uu$ a~set of items stored in the data structure,
 and $y\in\Uu\setminus X$ another item not stored in the data structure. Then
@@ -46,7 +56,7 @@ we have
 $$
 	\E_{h\in{\cal H}} [\#i: h(x_i) = h(y)] \le {cn\over m}.
 $$
-That is, the number of items that collide with~$y$ is at most $cn/m$.
+That is, the expected number of items that collide with~$y$ is at most $cn/m$.
 }
 
 \proof
@@ -73,18 +83,20 @@ Consider a~hash table with chaining which uses $m$~buckets and a~hash function~$
 picked at random from a~$c$-universal family. Suppose that the hash table contains
 items $x_1,\ldots,x_n$.
 	\tightlist{o}
-	\:An~unsuccessful search for an~item $y$~distinct from all~$x_i$
+	\:Unsuccessful search for an~item $y$~distinct from all~$x_i$
 	  visits all items in the bucket $h(y)$. By the previous theorem,
 	  the expected number of such items is at most $cn/m$.
-	\:Insertion of a~new item~$y$ takes constant time if we do not have
-	  to check that the item is not already present. If we have to check,
-	  it is equivalent to an unsuccessful search.
+	\:Insertion of a~new item~$y$ to its bucket takes constant time, but we have to verify
+	  that the item was not present yet. If it was not, this is equivalent
+	  to unsuccessful search.
 	\:In case of a~successful search for~$x_i$, all items visited in $x_i$'s bucket
 	  were there when $x_i$~was inserted (this assumes that we always add new
 	  items at the end of the chain). So the expected time complexity of the
 	  search is bounded by the expected time complexity of the previous
 	  insert of~$x_i$.
-	\:Finally, a~deletion takes the same time as successful search.
+	\:Unsuccessful insertion (the item is already there) takes the same time
+	  as successful search.
+	\:Finally, deletion takes the same time as search (either successful or unsuccessful).
 	\endlist
 Hence, if the number of buckets~$m$ is $\Omega(n)$, expected time complexity
 of all operations is constant. If we do not know how many items will be inserted, we can
@@ -118,7 +130,7 @@ say that a~family is \em{$k$-independent,} if it is $(k,c)$-independent for some
 \subsection{Constructions from linear congruence}
 
 \defn{For any prime~$p$ and $m\le p$, we define the family of linear functions
-${\cal L} = \{ h_{a,b} \mid a,b\in[p] \land a\ne 0\}$ from $[p]$ to $[m]$, where
+${\cal L} = \{ h_{a,b} \mid a,b\in [p] \}$ from $[p]$ to $[m]$, where
 $h_{a,b}(x) = ((ax+b) \bmod p) \bmod m$.
 }
 
@@ -127,7 +139,7 @@ $h_{a,b}(x) = ((ax+b) \bmod p) \bmod m$.
 \proof
 Let $x,y$ be two distinct numbers in $[p]$.
 First, we will examine the behavior of linear functions taken modulo~$p$
-without the final modulo~$m$ and without the restriction $a\ne 0$.
+without the final modulo~$m$.
 For an arbitrary pair $(a,b)\in [p]^2$ of parameters, we define
 $$\eqalign{
 	r & = (ax+b) \bmod p, \cr
@@ -136,38 +148,54 @@ $$\eqalign{
 This maps pairs $(a,b)\in [p]^2$ to pairs $(r,s)\in [p]^2$.
 We can verify that this mapping is bijective: for given $(r,s)$,
 we can solve the above equations for $(a,b)$. Since integers modulo~$p$
-form a~field, the system of linear equations (which regular thanks to $x\ne y$)
+form a~field, the system of linear equations (which is regular thanks to $x\ne y$)
 has a~unique solution.
 
-So we have a~bijection between $(a,b)$ and $(r,s)$, so picking $(a,b)$
-uniformly at random is equivalent to picking $(r,s)$ uniformly at random.
-Furthermore, the condition $a\ne 0$ is the same as $r\ne s$.
+So we have a~bijection between $(a,b)$ and $(r,s)$. This makes picking $(a,b)$
+uniformly at random equivalent to picking $(r,s)$ uniformly at random.
 
 Now, we resurrect the final modulo~$m$.
 Let us count \em{bad pairs} $(a,b)$, for which we have $h_{a,b}(x) = h_{a,b}(y)$.
 These correspond to bad pairs $(r,s)$ such that $r\equiv s$ modulo~$m$.
-We will fix~$r$ and count~$s$ for which $(r,s)$ is bad.
+Now we fix~$r$ and count~$s$ for which $(r,s)$ is bad.
 If we partition the set $[p]$ to $m$-tuples, we get $\lceil p/m\rceil$ $m$-tuples,
 last of which is incomplete. A~complete $m$-tuple contains exactly one number
-congruent to~$r$, the final $m$-tuple one or zero. However, we need $r\ne s$,
-so we skip the $m$-tuple containing~$r$.
+congruent to~$r$, the final $m$-tuple one or zero.
 
-Therefore for each~$r$, we have at most $\lceil p/m\rceil - 1$ bad pairs.
-We bound this by $(p+m-1)/m - 1 = (p-1)/m$. As we have~$p$ choices for~$r$,
-the number of all bad pairs is at most $p(p-1)/m$. As there are $p(p-1)$
-pairs in total, the probability that a~pair $(r,s)$ is bad is at most $1/m$.
+Therefore for each~$r$, we have at most $\lceil p/m\rceil \le (p+m-1)/m$ bad pairs.
+Since $m\le p$, this is at most $2p/m$.
+Altogether, we have~$p$ choices for~$r$, so the number of all bad pairs is at most
+$2p^2/m$.
+
+As there are $p^2$ pairs in total, the probability that a~pair $(r,s)$ is bad is at
+most $2/m$.
 Since there is a~bijection between pairs $(a,b)$ and $(r,s)$, the probability of
-a~bad pair $(a,b)$ is the same. The family~$\cal L$ is therefore 1-universal.
+a~bad pair $(a,b)$ is the same. The family~$\cal L$ is therefore 2-universal.
 \qed
 
-Surprisingly, if we modify the family slightly, it is even 2-independent.
+Surprisingly, a~slight modification of the family yields even 1-universality.
 
 \defn{For any prime~$p$ and $m\le p$, we define the family of linear functions
-${\cal L}' = \{ h_{a,b} \mid a,b\in [p] \}$ from $[p]$ to $[m]$, where
+${\cal L}' = \{ h_{a,b} \mid a,b\in[p] \land a\ne 0\}$ from $[p]$ to $[m]$, where
 $h_{a,b}(x) = ((ax+b) \bmod p) \bmod m$.
 }
 
-\theorem{The family~${\cal L}'$ is $(2,4)$-independent.}
+\theorem{The family~${\cal L'}$ is 1-universal.}
+
+\proof
+We shall modify the previous proof. The bijection between pairs $(a,b)$
+and $(r,s)$ stays. The requirement that $a\ne 0$ translates to $r\ne s$.
+We therefore have $p(p-1)$ pairs $(r,s)$. How many of those are bad?
+
+For a~single~$r$, we have one less bad choice of~$s$ (in the tuple
+containing~$r$), so at most $\lceil p/m\rceil - 1 \le (p+m-1)/m - 1 = (p-1)/m$
+bad choices. For all~$r$ together, we have at most $p(p-1)/m$ bad pairs,
+so the probability that a~random pair is bad is at most~$1/m$.
+\qed
+
+Now, we turn back to the original linear family~$\cal L$.
+
+\theorem{The family~${\cal L}$ is $(2,4)$-independent.}
 
 \proof
 We fix $x,y\in [p]$ distinct and $i,j\in [p]$. To verify $(2,4)$-independence,
@@ -193,10 +221,16 @@ is what we needed for $(2,4)$-independence.
 
 \subsection{Composition of function families}
 
+The proofs of 2-universality and (2,4)-independence of the family~$\cal L$
+have a~clear structure: they start with a~$(2,1)$-independent family from
+a~field to the same field. Then they reduce the family's functions modulo~$m$
+and prove that independence/universality degrades only slightly. This approach
+can be easily generalized.
+
 \lemmaxn{M}{composition modulo~m}{
 Let~$\cal H$ be a~$(2,c)$-independent family of functions from~$\Uu$ to $[r]$
 and $m<r$. Then the family ${\cal H} \bmod m = \{ h \bmod m \mid h \in {\cal H} \}$
-is $2c$-universal and $(2,4)$-independent.
+is $2c$-universal and $(2,4c)$-independent.
 }
 
 \proof
@@ -229,7 +263,7 @@ $$
 which guarantees $(2,4c)$-independence of ${\cal H}\bmod m$.
 \qed
 
-The previous proof generalizes quite easily to higher independence. However,
+The previous proof can be extended to general $k$-independence. However,
 instead of $4c$, we get $2^kc$, which grows steeply with~$k$. This is
 unavoidable for $m$~close to~$r$, but if we assume $r\gg m$, we can actually
 improve the constant even beyond the previous lemma.
@@ -242,7 +276,7 @@ is $(k,2c)$-independent.
 }
 
 \proof
-Let us generalize the previous proof. The family ${\cal H}\bmod m$ is $(k,c')$-independent for
+Let us extend the previous proof. The family ${\cal H}\bmod m$ is $(k,c')$-independent for
 $$
 	c' =
 	{c\over r^k} \cdot \left( r+m-1 \over m \right)^k =
@@ -253,9 +287,22 @@ Since $\e^x \ge 1+x$ for all real~$x$, we have $(1+m/r)^k \le (\e^{m/r})^k = \e^
 By premise of the lemma, $mk/r \le 1/2$, so $\e^{mk/r} \le \e^{1/2} \le 2$. Hence $c'\le 2c$.
 \qed
 
+\example{
+Let us test this machinery on the linear family~$\cal L$.
+The family of all linear functions in a~field is $(2,1)$-independent
+(by the bijection between $(a,b)$ and $(r,s)$ from the original proofs).
+Taken modulo~$m$, the family is 2-universal and $(2,4)$-independent by Lemma~\xx{M}.
+Whenever $p\ge 4m$, it is even $(2,2)$-independent by Lemma~\xx{K}.
+}
+
+The drawback of the reduction modulo~$m$ is that we needed a~2-independent family
+to start with. If it is merely universal, the modulo can destroy universality
+(exercise~\exref{modfail}). However, composing an~universal family with a~2-independent
+family (typically~$\cal L$) yields a~2-independent family.
+
 \lemmaxn{G}{general composition}{
-Let~$F$ be a~$c$-universal family of functions from~$\Uu$ to $[r]$.
-Let~$G$ be a~$(2,d)$-independent family of functions from $[r]$ to $[m]$.
+Let~$\cal F$ be a~$c$-universal family of functions from~$\Uu$ to $[r]$.
+Let~$\cal G$ be a~$(2,d)$-independent family of functions from $[r]$ to $[m]$.
 Then the family ${\cal H} = {\cal F}\circ{\cal G} = \{ f\circ g \mid f\in {\cal F}, g\in {\cal G} \}$
 is $(2,c')$-independent for $c' = (cm/r+1)d$.
 }
@@ -387,8 +434,8 @@ $$
 h(x) = \bigoplus_{0\le i<t} T_i[ \, x\slice{ik : (i+1)k} \,].
 $$
 
-Tabulation hashing can be considered a~system of hash functions, parametrized by the
-contents of the tables. Picking a~function from the system takes time $\Theta(t\cdot 2^k)$
+Tabulation hashing can be considered a~family of hash functions, parametrized by the
+contents of the tables. Picking a~function from the family takes time $\Theta(t\cdot 2^k)$
 to initialize the tables, evaluating it takes $\Theta(t)$.
 
 \claim{
@@ -442,32 +489,33 @@ yields a~uniformly random number; similarly, adding a~uniformly random number
 to any number yields a~uniformly random result.
 }
 
-As usually, we can reduce the result modulo~$m<p$. By Lemma~\xx{M}, the family
-${\cal S}\bmod m$ from~$\Zp^k$ to $[m]$ is 2-universal.
+What if the field is too large and we want to reduce the result modulo some~$m$?
+To use Lemma~\xx{M}, we need a~2-independent family, but~$\cal S$ is merely universal.
 
-To obtain 2-independence, we simply compose ${\cal S}$ with the $(2,4)$-independent
-family~${\cal L}'$ of linear functions. By Lemma~\xx{G}, the result will be a~$(2,8)$-independent family,
-or even $(2,5)$-independent if $p\ge 4m$.
+We can use Lemma~\xx{G} and compose~$\cal S$ with the family~$\cal L$ of linear
+functions from~$\Zp$ to~$[m]$. As~$\cal L$ is $(2,4)$-independent, ${\cal G}\circ{\cal L}$
+is $(2,8)$-independent. If $p\ge 4m$, $\cal L$ is $(2,2)$-independent and ${\cal G}\circ{\cal H}$
+$(2,c')$-independent for $c' = (1 + 1/4)\cdot 2 = 5/2$.
 
-The compound hash functions can be written as
-$(\alpha(\t\cdot \x) + \beta) \bmod m$, where
-$\t$ is a~vector parameter, and $\alpha$ and~$\beta$ are scalar parameters.
-However, $\alpha(\t \cdot \x)$ can be written as $\t' \cdot \x$
-for some vector $\t'$ and if $\t$ and $\alpha$ were uniformly
-distributed, so is~$\t'$. So we can define the compound family in a~more
-compact way:
+Alternatively, we can add an~additive constant to the scalar product:
 
-\defn{For a~prime~$p$, vector size $d\ge 1$, and the number of buckets~$m$,
+\defn{For a~prime~$p$, vector size $d\ge 1$,
 we define the family of scalar product hash functions
 ${\cal S}' = \{ h_{\t,\beta} \mid \t\in \Zp^d, \beta\in\Zp \}$
-from~$\Zp^d$ to $[m]$, where
-$h_{\t,\beta}(x) = (\t\cdot \x + \beta) \bmod m$.
-(The operations in parentheses are performed in the field~$\Zp$.)
+from~$\Zp^d$ to $\Zp$, where
+$h_{\t,\beta}(x) = \t\cdot \x + \beta$.
 }
 
-\theorem{If $p\ge 4m$, the family ${\cal S}'$ is $(2,5)$-independent.
-A~function can be picked at random from~${\cal S}'$ in time $\Theta(d)$
-and evaluated in the same time.}
+\theorem{
+If $p\ge 4m$, the family ${\cal S}' \bmod m$ is $(2,2)$-independent.
+A~function can be picked at random from the family in time $\Theta(d)$
+and evaluated in the same time.
+}
+
+\proof
+By exercise~\exref{sprimeindep}, the family $\cal S'$ is $(2,1)$-independent.
+By Lemma~\xx{K}, ${\cal S}' \bmod m$ is $(2,2)$-independent.
+\qed
 
 \subsection{Rolling hashes from polynomials}
 
@@ -495,13 +543,13 @@ the probability that $a$~is a~root is at most $d/p$. This implies $d$-universali
 \qed
 
 As usually, we can reduce the range of the function modulo~$m$. However, it is better
-to compose the family~$\cal R$ with the $(2,4)$-independent family~${\cal L}'$ of
+to compose the family~$\cal R$ with the $(2,4)$-independent family~${\cal L}$ of
 linear functions. Not only we get a~2-independent family as a~result, but Lemma~\xx{G}
 guarantees that if $p$~is sufficiently large, the big constant from $d$-universality
 disappears.
 
 \corr{Given a~prime~$p$ and the number of buckets~$m$ such that $p \ge 4km$, the
-compound family ${\cal R}\circ {\cal L}'$ is $(2,5)$-independent.}
+compound family ${\cal R}\circ {\cal L}$ is $(2,5)$-independent.}
 
 Hash functions of this kind play important role in the \em{Rabin-Karp string search
 algorithm.} Suppose that we are searching for a~$d$-character substring~$\nu$ (the needle)
@@ -543,10 +591,17 @@ is 1-independent.}
 \ex{Show that the family ${\cal L}'$ is not 1-universal. Find the smallest~$c$
 such that it is $c$-universal.}
 
-\ex{What if we modify the definition of ${\cal L}'$, so that it forces $b=0$?
+\ex{What if we modify the definition of ${\cal L}$, so that it forces $b=0$?
 Is the modified family $c$-universal for some~$c$? Is it 2-independent?}
 
-\ex{Prove that the family ${\cal L}'$ is not 3-independent.}
+\ex{Prove that the family ${\cal L}$ is not 3-independent.}
+
+\ex[modfail]{Show that taking an~universal modulo~$m$ sometimes destroys universality.
+Specifically, show that for each~$c$ and~$m>1$, there is a~family~$\cal H$ from some~$\Uu$
+to the same~$\Uu$ which is 2-universal, but ${\cal H}\bmod m$ is not $c$-universal.
+}
+
+\ex[sprimeindep]{Show that the family~${\cal S}'$ is $(2,1)$-independent.}
 
 \ex{Analyze expected time complexity of the Rabin-Karp algorithm, depending
 on haystack length, needle length, and the number of buckets.}