Restrcutred the generation process to delay linking objects untill the end.