file IO rework

Decided to keep a global map of loaded files in memory since many
entities can reference the same file. This way the entity code just
keeps MemRanges .

Compare that with the std::shared_ptr<MemRange<char>>  and the
HeapCharRange clumsy code.
cleanup of file IO

better error handling