\newcommand{\@usepackage}[1]
  {%\hva@warn{\@usepackage '#1'}%
  \def\pkg@arg{{\@nostyle\@callprim{\@eatspaces}{#1,}}}%
  \ifthenelse{\equal{\pkg@arg}{hevea}}{\@usepackage{comment}}
  {\ifu\csname\pkg@arg{}@loaded\endcsname
    \@iffileexists{\pkg@arg.hva}
       {\def\csname\pkg@arg{}@loaded\endcsname{foo}%
%Warning: loading \pkg@arg.hva may redefine \pgk@arg!!!!
       \input{\pkg@arg.hva}}
       {}%
    \fi}}
\newsavebox{\@pkg@opts}
\newcommand{\usepackagehook}[2]{}
\newcommand{\usepackage}[2][!*!]
{%\hva@warn{\usepackage '#1' '#2'}
\usepackagehook{#1}{#2}%
\ifthenelse{\equal{#1}{!*!}}
  {\sbox{\@pkg@opts}{}\begin{toimage}\usepackage{#2}\end{toimage}}
{\sbox{\@pkg@opts}{#1}\begin{toimage}\usepackage[#1]{#2}\end{toimage}}%
\@stopoutput\@stopimage%
\@funcall{\@iter}{\@usepackage,{#2}}%
\@restartimage\@restartoutput}
\hva@newstack{@pkg}\let\@pkg@me\relax
\hva@newstack{@pkg@opts}
\newcommand{\@pkg@pushs}
{%\typeout{Saving: '\@pkg@opts' '\@pkg@me'}
\@push@pkg{\@pkg@me}\@push@pkg@opts{\@pkg@opts}}
\newcommand{\@pkg@pops}
{\@pop@pkg@opts{\@pkg@opts}\@pop@pkg{\@pkg@me}%
%\typeout{Restoring: '\@pkg@opts' '\@pkg@me'}
}
\newcommand{\ProvidesPackage}[1]
{\def{\@pkg@me}{\@getprint{#1}}\AtEndOfFile{\@EndPackage}}
\newcommand{\@EndPackage}{}
\newcommand{\EndPackage}{\hva@warn{END}}
\newcommand{\@pkg@opt@name}[1]{@pkg\@pkg@me{}@#1}
\newcommand{\DeclareOption}[2]
  {\newcommand{\csname\@pkg@opt@name{#1}\endcsname}{#2}}
\newcommand{\@process@option}[1]%
	{\def\pkg@opt{{\@nostyle\@callprim{\@eatspaces}{#1,}}}%
        \ifu\csname\@pkg@opt@name{\pkg@opt}\endcsname
          \ifu\csname\@pkg@opt@name{@defopt}\endcsname
             \hva@warn{Ignoring option: '#1'}\else
             \csname\@pkg@opt@name{@defopt}\endcsname{#1}\fi
         \else
	 \csname\@pkg@opt@name{\pkg@opt}\endcsname\fi}%
%%Do not warn
\newcommand{\@@process@option}[1]%
	{\def\pkg@opt{{\@nostyle\@callprim{\@eatspaces}{#1,}}}%
        \ifu\csname\@pkg@opt@name{\pkg@opt}\endcsname\else
	 \csname\@pkg@opt@name{\pkg@opt}\endcsname\fi}%
\newcommand{\ProcessOptions*}
{\@callprim{\@iter}
  {\string\@@process@option,{\char123\usebox{\@document@opts}\char125}}%
\@callprim{\@iter}
  {\string\@process@option,{\char123\usebox{\@pkg@opts}\char125}}}
\newcommand{\ExecuteOptions}[1]
{\@callprim{\@iter}{\string\@process@option,{\{#1\}}}}
%%%% Packages in packages
\newcommand{\@GoobleOpt}[1][]{}%
\newcommand{\RequirePackage}[2][!*!]
{\@pkg@pushs\usepackage[#1]{#2}\execafter\@GoobleOpt\@pkg@pops}%
%%%%No op ProvidesFile
\newcommand{\@eatopt}[1][]{}
\newcommand{\ProvidesFile}[1]{\@eatopt}
%%%%Misc
\newcommand{\PackageInfo}[2]{\hva@warn{Package #1 info: #2}}
