Fix endless sprite loop bug