updated lib
updated lib
moved dir rel2abs after validate_directory as it was assuming pwd when dir not defined