Bug fixes for password handling