added parameters to set number of entities and nobg mode