Added missing calls to setHeaders() and outputHeader()