Ugly but semi functional directory managment stuff in place