major rewrite of batchmode backprop