USB fixes from Petteri Aimonen, cherry-picked.