Better error handling on sprite. Refactored.