Refactor user and repository functions into separate files.