massive client refactoring and cleanup - step 2