Updated code to make clearFrame faster.