Refactor initialization of dirs