Fix term precedence in expand