Made directory creation better extensible.