Added horizontal and vertical flipping support.