Fixed a bug in the flipHorizontal function, and some of the attempts to compensate for it