Fix infinite loop in expander