nine/device: oops accidentally reverted clear patch, add some fixes

In 4b7cd98c64eca53a9f84d9d2d4c89374281a8d46.