Ensure that hostname setting is permanent

Fixes issues raised in #712 and #719