merge relevant part of pull request #48 (DP)