Fixed a bug to do with setting x,y positions in the render function