fix directory reference and some of weird require order