Fixed NPE when there are no headers sent
Added mime-type for .zip
Debug output file written