Improve parallelization and add debugging messages.