fix counter for problems

Make counter for problems behave more nicely.  Also move all commands to
command.tex