try adding some pointer protection
add comments
something is wrong with xy_to_bufferpt