Fixed NPE caused by null x and y.