Refactoring and bug fixes in client and server. Added more extended statistics functionality.