Added Directory check (in rename) after unlink call to make sure mkdir and chown on directory only