Replaces PR #815 Shipping files fixes

Replaces PR #815, which fixes #683, #793, #803, #865, #870. There were
too many changes to deal with, so I decided it was faster to start from
scratch.