Fixing memory leaks and unsafe attribute casting

There are some memory leaks in the unit texture outlines and locations, and unsafe operations with the attributes. This fixes the leaks and puts compile time restrictions on attribute typing
Shouldn't this be a `shared_ptr`?  I think one texture must be shared by multiple terrain objects.