Prevent a crash when a sprite could not be loaded.
Additional tweaks and cleanup for scripts