Performance improvements and some fixes

Performance has been improved by about facto 10. I exchanged x, y coordinates since you seem to have mixed them up...

I'll implement the rotated ellipse functions in a separate PR, so that you should implement the example afterwards in a new PR. Is that OK?