sync with latest changes from master version 3.1.0