Backup of Slightly improved sprite generation algorithm

Sprite generation algorithm somewhat more efficient.