Graphic optimizations 3

A couple of small optimizations but most notably a faster EOF check which is very hot code with ~10M calls for the document in issue2813