bugs in nn code fixed