Improve performance

Instead of trimming all the nodes at once, they're trimmed in batches. This
improves performance overall while the page is loading.

Since nodes are trimmed first-to-last, there's no apparent difference to the end
user.