refs #209 Refactor for clarity and hopefully code reuse later.