Engine code restructure to get all tests working