Bug fixes and preparation for deploying to device.