Code is copied from https://github.com/prs-eth/Marigold. Modifications are indicated within the code.