Change MAX_PORTALS (0x1000) to MAX_BSP_PORTALS (0x10000). Also gracefully catch VIS overflow rather than segfaulting.
Precache health and armor so that the HUD icons are available even on maps which don't have these items.