Fix bug and refactor run_in_batch into function.
Fix bug and refactor run_in_batch into function.

pvtodorov/indra,johnbachman/belpy,bgyori/indra,johnbachman/indra,johnbachman/belpy,pvtodorov/indra,johnbachman/indra,sorgerlab/indra,sorgerlab/indra,sorgerlab/indra,bgyori/indra,bgyori/indra,sorgerlab/belpy,sorgerlab/belpy,johnbachman/belpy,pvtodorov/indra,johnbachman/indra,sorgerlab/belpy,pvtodorov/indra