Implement #19

With immense thanks to Trevor Perrin