mostly done refactoring the .def code