made HOSTNAME references more dynamic. added PRODUCTION config option