enabling more code reuse and modularity with prepare_image.
remove unused code
diffing by layer. things look same up to pad1... then pad2 diverges a lot.