Fixed export to contain headers; Minor bug fixes