Optimized chunk loader

Fixes #1486 
`static_cast<size_t>`