Accounts rest endpoint

Changes and refactorings to account rest endpoint.