Councils take back direct control of 17,000 homes