Cleanup fragment generation code