Remove warnings on SL6.

There were lots of constructions %$foo->, and duplicate variable
declarations, which are deprecated and wrong.  Declare variables only
once and replace hash dereferences with $foo->.