Dpawluk/rebase mikealmond

This is the same as Mikealmonds PR #28 except I've rebased it and cleaned up merge conflicts by hand. Thanks again for the help @mikealmond.

@maximeprades :+1: (I've triple checked this one, all good).