clean up frame extraction code