start refactoring out filesystem code into a dedicated file