Merge PR #4499 and compilation fixes

Merge PR #4499 and compilation fixes