Fix bugs and remove double sheets from header.