Clean up NEI handler code quite a bit.