Fixing the pixel wrapping algorithm.