speedup of graph handling code
added generic support for screen rotation