Refactor routing and authentication. Use namespace API for API call from client