fix bugs with sprite row advancing and end of sprite detection.