Refactor output functions.