Apply @Arfrever patch, fixes #258