Improved Authkey generation.

Replaced auth-key generation with more solid version.
Made autocomplete directory generation more resiliant.