Further fixes to generate direct loops