merged bugs fixes in branch 4.1