Proposed fix for issue raised in https://gist.github.com/octete/a6877294c0bc61966154/. Tested like so https://gist.github.com/grahaminn/d593291f24658b955e9b