Bug fix #3543

And more optimization!!!