getPosition workaround for X11. Fixed memory leaks.