Improved loop analysis; more tests