Finishing unique_ptr'ing and fixing file memory management (for now).