Added batch processing (single level) and fixed some bugs.