Refactored to use less memory
Broken using 16 images + numpy, benchmark 65 seconds