Fix several issues and add NEI support (untested)