[major] complete rewrite of file module