Rewrote scale algorithm. Needs to be tested (flip)