Greatly improved clipping mask application and fixed out of bounds bugs