xan: Add some buffer checks