More refactoring. Moved output related stuff out of Pest.cpp.