Work on bug found by Jean-Damien Durand
Fixed bug found by Jean-Damien Durand