Better batch state handling + setup for built in layout/program sorting