Refactored result-writing methods to be more simple.