Updated method for updating passwords & tweaked queries for finding them

Closes #2521 (again)

This should hopefully fix any problems with saving a password over an existing entry.

Again this commit will get cherry-picked into 4.5.

cc: @koke @sendhil