Refactor passwords API