parse frames to remove invalid layers