Several improvements to batch JS