fix #504
Some refactoring .
Merge branch '3.1-stable'
correct Changelog and version bump to avoid conflict.