Fixed bugs in sprite rendering