major code restructure