break out slug code and also let alternate names table's memory be freed before outputting hfile