Add a guard on nCount with MAXIMUM_WAIT_OBJECTS + cosmetic fixes