Fixed buggy sprite cache, some optimizations to sprite rendering