Improve read logic for XegerGen