Manually added code of pull request #140 from GnomeffinWay/master