refactor dir struct and some other stuff