heavily refactor server, add loading states