incorporated bugfix from kleinschmidt