more fixes to the new device code, and some undos of my earlier code