Add types to indicate the response from the server.
Move internal functions into the internal module and commands into their own.