Chunking the reading of resources to avoid hitting ulimit.

Closes #347