add client factory
minor
fix typo
move globals to class level