Use function size instead of segment size
xseg: Improve error handling