JAIF fix

Everything except c172bde and 7ae2afb is directly fix for writing to JAIF. (Testing of JAIF writing relies on c172bde and 7ae2afb, so they are included in this pull request). A side effect of 7ae2afb is that now `@Nullable` is always written into JAIF or xml. This will be controlled soon by an extra option.