added coordinate transform. not sure if works. also added debug stuff for drawing