JAIF fix

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