Trying to hide blocks of text in beamer

Here's a way of defining a \hideit using Beamer's extended \newcommand:

\documentclass[handout]{beamer}

\setbeamercolor{math text}{fg=blue}

\newcommand\hideit[1]{%
  \only<0| handout:1>{\mbox{}}%
  \invisible<0| handout:1>{#1}}

\begin{document}

\begin{frame}
  \frametitle{Two bugs:}
  {\color{red}Error with itemize}
  \begin{itemize}
    \item The line below should have a `bullet' (only the
    text should be hidden)
    \item \hideit{Some text to be hidden}
    \item This is visible again.
  \end{itemize}

  \bigskip

  {\color{red}Error with beamer's pause command:}

  \textbf{Example 1:}\quad  Differentiate \ $f(x)=x^2\sin x$

  \bigskip
  \underline{\itshape Solution:}
  \hideit{Let $u=x^2$ and $v=\sin x$. (this line should be hidden)

    \pause  Then $u'=2x$ and $v'=\cos x$.

    Using the product rule we get
    $$f' = 2x\sin x + x^2\cos x.$$
  }
\end{frame}

%%%%%%%%%%%
\begin{frame}
  \frametitle{Two more bugs:}

  {\color{red}Error with `inline' hiding:}

  Here is some \hideit{hidden} text on one line.

  \bigskip

  {\color{red}Error with eqnarray* in beamer:}

  \textbf{Example 1:}\quad  Differentiate \ $f(x)= \frac{\sin x}{e^x}$.

  \medskip

  \underline{Solution:} Let $u=\sin x$ and $v=e^x$.
  Then $u'=\cos x$ and $v'=e^x$.  Therefore

  \hideit{\begin{eqnarray*}
      f'(x) &=& \frac{e^x\cos x-(\sin x)e^x}{(e^x)^2} \\
      &=& \frac{e^x(\cos x-\sin x)}{(e^x)^2} \\
      &=& \frac{\cos x-\sin x}{e^x}.
    \end{eqnarray*}
  }

  And that's how you do it! (This should be black text)

\end{frame}
\end{document}

handout

And for the presentation:

slides


I shortened the example to show the relevant feature with \mode<handout>{...} and \mode<beamer>{...}, which is basically beamer's own way of \hideit etc.

\documentclass[handout]{beamer} 

\setbeamercolor{math text}{fg=blue}

%%%%
\begin{document}

%%%%%%%%%%%
\begin{frame}{Two bugs:}
%\frametitle{Two bugs:}
%{\color{red}Error with itemize}

\begin{itemize}
\item The line below should have a `bullet' (only the text should be hidden)
  \mode<handout>{%
  \item 
  }%
  \mode<beamer>{%
  \item Some text to be hidden
  }%
  \item This is visible again.
  \end{itemize}
\end{frame}
%%%%%%%%%%%
\end{document}

Beamer mode

enter image description here

Handout mode enter image description here