#2261: preparations for trunk integration (adapt to current trunk version, add license headers, add comments, improve code quality)