Major bug fix in frame processing