Spivak, Calculus on Manifolds 3-40 Looking for a hint to the following question:

If $g: \mathbb{R}^n \to \mathbb{R}^n$ is continuously differentiable and $\det g'(x) \neq 0,$ prove that in some open set containing $x$ we can write $g = T \circ g_n \circ \ldots \circ g_1,$ where $g_i$ is of the form $g_i(x) = (x^1, \ldots, f_i(x), \ldots, x^n),$ and $T$ is a linear transformation.

Since $g$ is $C^1$ we can apply the inverse function theorem, and obtain an open set $A$ containing $x$ where $g$ is one to one. Since this problem is in the section on change of variables, I assume it can be used in the solution. I state it below as Spivak states it.

Let $A \subset \mathbb{R}^n$ be an open set and $g: A \to \mathbb{R}^n$ be a 1-1, continuously differentiable function such that $\det g'(x) \neq 0$ for all $x \in A$. If $f: g(A) \to \mathbb{R}$ is integrable, then $$\int_{g(A)}f = \int_Af \circ g|detg'|.$$

I've managed to produce the conditions on $g$ necessary for change of variables but I have no clue as to how to apply it. Considering just the representation of $g$ stated in the problem, it seems to be a composition taking $x$ to $g(x)$ coordinate by coordinate. 
Can anyone give me a hint? 
 A: Note. I came up with this sketch by following the discussion at the end of p. 69 in Spivak's book, so you can refer to that for more ideas. The idea is to cut down the number of variables one-at-a-time in a sort of "recursive" fashion using the trick you will see below.

Sketch of Proof. Let us look at the case $n = 3$ and use $a$ for what Spivak denotes $x$ to reserve $x$ for a general variable. Then the claim is that there is an open set $W$ containing $a$ such that
$$
g(x) = \big(T\circ g_3\circ g_2\circ g_1\big)(x)\quad \text{for $x\in W$},
$$
and such that $g_1(x) = \big(f_1(x),x^2,x^3\big)$, $g_2(x) = \big(x^1,f_2(x),x^3\big)$, and $g_3(x) = \big(x^1,x^2,f_3(x)\big)$.
First, let us assume that $g'(a) = I$, the $3\times 3$ identity matrix. If we manage to prove the claim is true in this case, then we will have proved it more generally by considering $S = g'(a)$ and $S^{-1}\circ g$.
Define $h(x) = \big(g^1(x),g^2(x),x^3\big)$. Then $h'(a) = I$. Hence in some open set $U$ with $a\in U$, the function $h$ is $1$-$1$ and $\det h'(x) \ne 0$ for $x\in U$, by the Inverse Function Theorem. Define $g_3\colon h(U)\to \mathbf R^3$ by $g_3(x) = \big(x^1,x^2,g^3(h^{-1}(x))\big)$, so that $g = g_3\circ h$.
Define $k(x) = \big(h^1(x),x^2,x^3\big) = \big(g^1(x),x^2,x^3\big)$. Then $k'(a) = I$. Hence in some open set $V$ with $a\in V$, the function $k$ is $1$-$1$ and $\det k'(x) \ne 0$ for $x\in V$, by the Inverse Function Theorem. Define $g_2\colon k(V)\to \mathbf R^3$ by $g_2(x) = \big(x^1,h^2(k^{-1}(x)),x^3\big)$, so that $h = g_2\circ k$:
\begin{align*}
(g_2\circ k)(x) &= g_2\big(h^1(x),x^2,x^3\big) = g_2(k(x)) \\
&= \Big(h^1(x),h^2\big(k^{-1}(k(x))\big),x^3\Big)\\
&= \big(g^1(x),h^2(x),x^3\big) \\
&= \big(g^1(x),g^2(x),x^3\big) = h(x).
\end{align*}
Finally, set $g_1 = k$. We are done with $T = I$ and the open set $W = U\cap V$ containing $a$, since
$$
g = g_3\circ h = g_3\circ(g_2\circ k) = I\circ g_3\circ g_2 \circ g_1.
$$
