Code cleaning and bugs correction. Patch by Hermès Bélusca. See issue #7128 for more details. svn path=/trunk/; revision=56754