[#1855] Set MAX_PASSWORDS to the number of rows in the database
[#1855] Fix to make sure there is no infinite loop if the user has no passwords.
[#1855] Fixed the SQL query so that it only returned the number of passwords for the specified user.
Merge with master