some bug fixes. Works.
move NI error to initialization