Array ports

Fixes #597, plus some unrelated but localized cleanup.