Fixed a bug and cleaned code.  Refs #6968.