general code cleanup
Merge pull request #6378 from lucasmichot/5.0-eof-fix

[5.0] Global CS Fixes