Fix bugs in new STATIC_OUTPUT_BUF macro