TITLE: Continuity on a measure one set versus measure one set of points of continuity
QUESTION [16 upvotes]: In short: If $f$ is continuous on a measure one set, is there a function $g=f$ a.e. such that a.e. point is a point of continuity of $g$?
Now more carefully, with some notation: Suppose $(X, d_X)$ and $(Y, d_Y)$ are metric spaces, with Borel sets $\mathcal B_X$ and $\mathcal B_Y$, respectively.  Let $f:(X, \mathcal B_X) \rightarrow (Y, \mathcal B_Y)$ be a measurable function and let $\mu$ be a probability measure on $(X, \mathcal B_X)$.
Say that $f$ is almost continuous if there is a $\mu$-measure-one Borel set $D \subseteq X$ such that $f$ is continuous on $D$, i.e., the restriction $f|_D:D \rightarrow Y$ is a continuous function where $D$ is given the subspace topology.
As usual, we say that $x \in X$ is a point of continuity (for $f$) if, for every Cauchy sequence $(x_n)_{n\in\mathbb{N}}$ that converges to $x$, we have that $(f(x_n))_{n \in \mathbb{N}}$ is a Cauchy sequence that converges to $f(x)$.
Let $C$ be the set of all points of continuity of $f$.  (A classic result [Kechris, I.3.B Prop 3.6] shows that $C$ is a $G_\delta$ set.)  Say that $f$ is almost everywhere (a.e.) continuous if $C$ is a $\mu$ measure-one set., i.e. $\mu$-a.e. point is a point of continuity.
Finally, say that a measurable function $g$ is a version of $f$ if $f=g$ $\mu$-a.e.
Clearly, if $f$ is a.e. continuous, then it is almost continuous on the set $C$.  The converse does not hold in general: Consider for $f$ the indicator function for the rationals in $[0,1]$.  Then $f=0$ on the irrationals, a Lebesgue-measure-one set, but $f$ is discontinuous everywhere.  
However, $g=0$ is a version of $f$ and $g$ is a.e. continuous.  Which raises the question:  
If $f$ is almost continuous, is there a version $g$ of $f$ such that $g$ is a.e. continuous?
If it is helpful, one may assume that both $X$ and $Y$ are also complete and separable, i.e., Polish.
Note that by a result of Kuratowski [Kechris, I.3.B Thm. 3.8], if $Y$ is complete, we can, possibly changing versions, assume, without loss of generality, that $f$ is continuous on a $\mu$-measure-one $G_\delta$-set $D$.  (In the example above, $f$ is almost continuous on the irrationals, which are of course $G_\delta$.)

[Kechris: "Classical Descriptive Set Theory" 1995]

REPLY [9 votes]: As Jason and Gerald predicted, the answer is yes for Polish $X, Y$. (Indeed, it is sufficient for $X$ to be merely separable and metrizable and for $Y$ to be merely complete and metrizable.)
As Nate observed, we may assume that $D$ is $G_\delta$. Here is the key fact:
Lemma. If $D \subseteq X$ is a nonempty $G_\delta$-set then there is a Borel map $h:X \to D$ such that $\lim_{x\to x_0} h(x) = x_0$ for every $x_0 \in D$.
Suppose $D = \bigcap_{n\lt\omega} U_n$, where $(U_n)_{n\lt\omega}$ is a descending sequence of open sets such that $U_n \subseteq \bigcup_{x_0 \in D} B(x_0,1/(n+1))$. Any Borel retraction $h:X \to D$ with the property that if $x \in U_n \setminus U_{n+1}$ then $d(h(x),x) \lt 1/(n+1)$ will be as required. By definition, it is always possible to find a suitable $h(x) \in D$ for each $x \in U_0 \setminus D$. To ensure that $h$ is Borel, fix an enumeration $(d_i)_{i \lt \omega}$ of a countable dense subset of $D$ and, if $x \in U_0 \setminus D$, define $h(x)$ to be the first element in this list that matches all the necessary requirements. (We must have $h(x) = x$ for $x \in D$ and it doesn't matter how $h(x)$ is defined when $x \notin U_0$ so long as the end result is Borel.)
Now, if $f:X \to Y$ is Borel and continuous on $D$, then $g = f\circ h$ is a Borel function that agrees with $f$ on $D$ and $$\lim_{x \to x_0} g(x) = f(\lim_{x \to x_0} h(x)) = f(x_0) = g(x_0)$$ for all $x_0 \in D$.