begin code organisation
more refactoring, added .close() on file dscrptrs