code restructuring, and a few batch changes