Improved batch task and some cleaning up