reorganize so that fileserver can be used as a library