Fixed nested masks and changed render logic.