If you're pretty sure that what you have is correct, another part of the solution could be simply marking loops to be aggressive by using: options {greedy=true; };