Code cleanup and fixed correct frame number detection based on video frame rate.