fixed many bugs in arbitrary Nc code