lots of small cleanup for the mobile code.