Refactor script and sprite loading.