Move output buffer clearing to individual handlers