Small changes to ease debugging
Limit number calls to global optimizers

It helps locating infinite loops
Add DestroyHandler if there are inplace ops

Even in DebugMode, even before the inplace phase.
Update following code review
Merge pull request #1180 from lamblin/fix_infinite_opt_loop

Fix infinite opt loop