Generation of random passwords with some fixes

Commit messages should make the changes apparent.