Biiiiiiig refactoring and some improvements in both server and client
Merge