Improved the way client is created to allow better extendability