xseg: Improve error handling