Reorganize some HUD code