Re-implement prepare_output() usage

Accidentally took this out when moving around code.