Fixes #517
rebased onto 3f54627ffe93625be1e9c7089e2ec29299a085e4
LGTM, thank you!
Pull-Request has been merged by pbokoc
Fixes #517