bugfixes to new <if> and related code