Added support of filtering for generateAll, and fixed some bugs.