Made cursor position resolution more portable