Twiddle the order of the some of the export logic

This commit makes the order that the {write_tree,write_level,write_rank}
boolean logic gets visited consistent throughout the file.