correct all the ref indices
delete invalid empty lines
correct the format of the page headers