put templated cases into a separate file, and refactor other parts accordingly