Change algorithm of device type saving
Merge branches 'save_client_type' and 'master'