rewrite of file module

work in progress