Refactored load and load_chunk to remove duplication.