Removed some debug code.
Fixed horizontal flip. Some cleanup.
Version that uses the CPU instead.