Refactor Endpoint stuff