Performance enhancements, and resource completion

I've optimized the stable parts of the code, and have now properly
managed the resources.  Probably a lot of other stuff has changed, but
it is now a stable build that has basic nation functionality.