Fixing bug with Sprite generation

More accurate check for name conflict. This is a work in progress and
does not fully fix the problem yet.