FIXED #23. Refactoring code of client factory.