improved batch handling + code clean up