refactor implementation of AppDir and HomeDir