Fix password display and refactor some code