A few changes to make the engine fail gracefully

When there's no script to run, it shuts down gracefully. If there's no
ID assigned to a drawable/material/texture when tracking a texture, it
produces an error and bails out.
Some memory management code for future threading

Going to use state duplication, will likely support reusing memory in
the future to save on allocations