issue #677, directly fill the header struct inside memory instead of copying it