Added better error handling to xp2xm