massive client side refactoring