Major refactoring of client module