Move writer code to keep ordering consistent with public functions