Fixed bug 951709, changed the HOSTNAME variable to APP_HOSTNAME
[bug951709] - Follow up on a bug. Rebased with recent master, updated, fixed conflicts