Fixes and improves extract_local_patches_fast