Don't die if a script makes an error with a sprite (#151).

Also improve error messages and general code of sprites.