big refactoring to make code cleaner and easier to understand
server refactoring; client & server now share most of the business logic