merged patch provided by c.hoeflake in #355