cleaned up the sprite layer code a little bit