Refactored much of server+client implementation.