This code has been ported from https://github.com/anbclausen/quills by Kostiantyn V. Milkevych.
