Refactored repositories to use new Gateway functions