fixed clipping and flipping bugs