port from dr-commons
initial extract from dr-commons