Fix occasional segfaults when prompting for password. Fixes #83