Remove bug in end of file management.
Optimize end of file management.