Refactoring for better modularity
Refactoring, spliting client files and simplifying code